1. <small id='MjnaG'></small><noframes id='MjnaG'>

          <bdo id='MjnaG'></bdo><ul id='MjnaG'></ul>
      1. <i id='MjnaG'><tr id='MjnaG'><dt id='MjnaG'><q id='MjnaG'><span id='MjnaG'><b id='MjnaG'><form id='MjnaG'><ins id='MjnaG'></ins><ul id='MjnaG'></ul><sub id='MjnaG'></sub></form><legend id='MjnaG'></legend><bdo id='MjnaG'><pre id='MjnaG'><center id='MjnaG'></center></pre></bdo></b><th id='MjnaG'></th></span></q></dt></tr></i><div id='MjnaG'><tfoot id='MjnaG'></tfoot><dl id='MjnaG'><fieldset id='MjnaG'></fieldset></dl></div>
      2. <legend id='MjnaG'><style id='MjnaG'><dir id='MjnaG'><q id='MjnaG'></q></dir></style></legend>
        <tfoot id='MjnaG'></tfoot>

        从 :hover with .css() 获取 css 值 - jquery

        时间:2023-11-29
        • <bdo id='0O7Mq'></bdo><ul id='0O7Mq'></ul>

        • <small id='0O7Mq'></small><noframes id='0O7Mq'>

          • <legend id='0O7Mq'><style id='0O7Mq'><dir id='0O7Mq'><q id='0O7Mq'></q></dir></style></legend>

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

                    <tbody id='0O7Mq'></tbody>
                1. 本文介绍了从 :hover with .css() 获取 css 值 - jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我设置了一个具有不同背景的菜单:悬停颜色.按钮背景将是灰色,并且在将按钮 animate() 悬停到其各自的颜色时.

                  So Im setting up a menu that has different background :hover colors. The buttons backgrounds will be a grey color and upon hover the button animate() to its respective color.

                  我可以像这样抓住悬停在任何按钮上的原始默认颜色:

                  I can grab the original default color of whatever button I hover over like this:

                  var origBackgroundColor = $(this).css('background-color');
                  

                  但是是否可以从我设置的 css :hover 属性中获取颜色?我将为每个按钮设置 :hover 颜色,因为如果有人没有启用 JS,导航仍然会具有 :hover 效果.

                  But is it possible to get the color from a css :hover property that I set? I will have the :hover colors set for each button because if someone doesn't have JS enabled the navigation will still have :hover effects working.

                  类似这样的东西(或者还有其他方法):

                  Something like this(Or is there another way):

                  var hoverColor = $(this).css('background-color:hover');
                  

                  有什么想法吗?这可能吗?

                  Any ideas? is this possible?

                  推荐答案

                  我很确定为了得到 :hoverbackground-color 伪,它首先需要一个浏览器事件来应用样式.换句话说,我认为你用鼠标悬停时你可以得到它,但直到那时.

                  I'm pretty sure that in order to get the background-color of the :hover pseudo, it will first require a browser event to apply the style. In other words, I think you could get it when you do a hover with the mouse, but not until then.

                  可能你可以等到用户悬停,然后抓取颜色,用默认值覆盖它,存储它以供将来参考,然后制作动画,但这可能比简单地协调你的 JS 和CSS.

                  Could be that you could wait until the user does a hover, then grab the color, override it with the default, store it for future reference, then do your animation, but that may be more trouble that simply coordinating your JS and CSS.

                  类似这样的:http://jsfiddle.net/UXzx2/

                      // grab the default color, and create a variable to store the hovered.
                  var originalColor = $('div').css('background-color');
                  var hoverColor;
                  
                  $('div').hover(function() {
                        // On hover, if hoverColor hasn't yet been set, grab the color
                        //    and override the pseudo color with the originalColor
                      if( !hoverColor ) {
                          hoverColor = $(this).css('background-color');
                          $(this).css('background-color',originalColor);
                      }
                        // Then do your animation
                      $(this).animate({backgroundColor:hoverColor});
                  });
                  

                  这篇关于从 :hover with .css() 获取 css 值 - jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:具有 Rowspan 悬停和斑马效果的表格 下一篇::hover 在 IE9 中无法正常工作

                  相关文章

                    <bdo id='8KoDM'></bdo><ul id='8KoDM'></ul>
                2. <tfoot id='8KoDM'></tfoot>

                  <small id='8KoDM'></small><noframes id='8KoDM'>

                  <legend id='8KoDM'><style id='8KoDM'><dir id='8KoDM'><q id='8KoDM'></q></dir></style></legend>
                3. <i id='8KoDM'><tr id='8KoDM'><dt id='8KoDM'><q id='8KoDM'><span id='8KoDM'><b id='8KoDM'><form id='8KoDM'><ins id='8KoDM'></ins><ul id='8KoDM'></ul><sub id='8KoDM'></sub></form><legend id='8KoDM'></legend><bdo id='8KoDM'><pre id='8KoDM'><center id='8KoDM'></center></pre></bdo></b><th id='8KoDM'></th></span></q></dt></tr></i><div id='8KoDM'><tfoot id='8KoDM'></tfoot><dl id='8KoDM'><fieldset id='8KoDM'></fieldset></dl></div>