• <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 属性

        Adding hover CSS attributes via jQuery/Javascript(通过 jQuery/Javascript 添加悬停 CSS 属性)
        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 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  Rounded corners on chartJS v.2 - bar charts (with negative values)(chartJS v.2 上的圆角 - 条形图(带负值))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)
                  <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>
                    <tbody id='KZiRC'></tbody>

                      <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>