• <tfoot id='XJlIy'></tfoot>

      <i id='XJlIy'><tr id='XJlIy'><dt id='XJlIy'><q id='XJlIy'><span id='XJlIy'><b id='XJlIy'><form id='XJlIy'><ins id='XJlIy'></ins><ul id='XJlIy'></ul><sub id='XJlIy'></sub></form><legend id='XJlIy'></legend><bdo id='XJlIy'><pre id='XJlIy'><center id='XJlIy'></center></pre></bdo></b><th id='XJlIy'></th></span></q></dt></tr></i><div id='XJlIy'><tfoot id='XJlIy'></tfoot><dl id='XJlIy'><fieldset id='XJlIy'></fieldset></dl></div>

      <small id='XJlIy'></small><noframes id='XJlIy'>

      1. <legend id='XJlIy'><style id='XJlIy'><dir id='XJlIy'><q id='XJlIy'></q></dir></style></legend>
          <bdo id='XJlIy'></bdo><ul id='XJlIy'></ul>

      2. 通过 jQuery/Javascript 添加悬停 CSS 属性

        时间:2023-11-01
        1. <tfoot id='J9CaQ'></tfoot>
        2. <legend id='J9CaQ'><style id='J9CaQ'><dir id='J9CaQ'><q id='J9CaQ'></q></dir></style></legend>
                <tbody id='J9CaQ'></tbody>

              <small id='J9CaQ'></small><noframes id='J9CaQ'>

              <i id='J9CaQ'><tr id='J9CaQ'><dt id='J9CaQ'><q id='J9CaQ'><span id='J9CaQ'><b id='J9CaQ'><form id='J9CaQ'><ins id='J9CaQ'></ins><ul id='J9CaQ'></ul><sub id='J9CaQ'></sub></form><legend id='J9CaQ'></legend><bdo id='J9CaQ'><pre id='J9CaQ'><center id='J9CaQ'></center></pre></bdo></b><th id='J9CaQ'></th></span></q></dt></tr></i><div id='J9CaQ'><tfoot id='J9CaQ'></tfoot><dl id='J9CaQ'><fieldset id='J9CaQ'></fieldset></dl></div>

                  <bdo id='J9CaQ'></bdo><ul id='J9CaQ'></ul>

                • 本文介绍了通过 jQuery/Javascript 添加悬停 CSS 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Some CSS styles need to be applied to an element on hover, and CSS styles have to be applied using javascript/jquery directly and not through stylesheets or $(this).addClass('someStyle') because I am injecting the DOM elements into another page.

                  We can apply the usual css styles using

                  $('#some-content').css({
                      marginTop: '60px',
                      display: 'inline-block'
                  });
                  

                  How should we add the CSS styles for :hover events?


                  Do we have to resort to:

                  $('#some-content').hover(
                         function(){ $(this).css('display', 'block') },
                         function(){ $(this).css('display', 'none') }
                  )
                  

                  解决方案

                  I find using mouseenter and mouseleave to be better than hover. There's more control.

                  $("#somecontent").mouseenter(function() {
                      $(this).css("background", "#F00").css("border-radius", "3px");
                  }).mouseleave(function() {
                       $(this).css("background", "00F").css("border-radius", "0px");
                  });
                  

                  这篇关于通过 jQuery/Javascript 添加悬停 CSS 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用jquery动态更改背景颜色后,背景颜色的CSS悬停选择器不起作用 下一篇:如何使用css在悬停时在图像上显示图像

                  相关文章

                  <i id='KZiRC'><tr id='KZiRC'><dt id='KZiRC'><q id='KZiRC'><span id='KZiRC'><b id='KZiRC'><form id='KZiRC'><ins id='KZiRC'></ins><ul id='KZiRC'></ul><sub id='KZiRC'></sub></form><legend id='KZiRC'></legend><bdo id='KZiRC'><pre id='KZiRC'><center id='KZiRC'></center></pre></bdo></b><th id='KZiRC'></th></span></q></dt></tr></i><div id='KZiRC'><tfoot id='KZiRC'></tfoot><dl id='KZiRC'><fieldset id='KZiRC'></fieldset></dl></div>
                  • <bdo id='KZiRC'></bdo><ul id='KZiRC'></ul>

                  <small id='KZiRC'></small><noframes id='KZiRC'>

                  <legend id='KZiRC'><style id='KZiRC'><dir id='KZiRC'><q id='KZiRC'></q></dir></style></legend>
                    <tfoot id='KZiRC'></tfoot>