大佬教程收集整理的这篇文章主要介绍了获取css值:hover with .css() – jquery,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以抓住原来的默认颜色,无论如何,我将鼠标悬停在此上面:
var origBACkgroundColor = $(this).css('BACkground-color');
但是可以从我设置的css:hover属性获取颜色吗?我将具有:为每个按钮设置的悬停颜色,因为如果有人没有启用JS,导航将仍然具有:悬停效果工作.
这样的东西(或有另一种方式):
var hoverColor = $(this).css('BACkground-color:hover');
有任何想法吗?这可能吗?
可以这样,你可以等到用户做一个悬停,然后抓住颜色,用默认值覆盖它,存储它以供将来参考,然后做你的动画,但这可能是更麻烦的只是协调你的JS和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}); });
以上是大佬教程为你收集整理的获取css值:hover with .css() – jquery全部内容,希望文章能够帮你解决获取css值:hover with .css() – jquery所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。