我试图在鼠标悬停时使用jQuery为backgroundColor中的更改设置动画.
我已经检查了一些例子,我似乎做对了,它适用于其他属性,如fontSize,但我使用backgroundColor和"无效属性"js错误.我正在使用的元素是div.
$(".usercontent").mouseover(function() {
$(this).animate({ backgroundColor: "olive" }, "slow");
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
使用颜色插件在悬停时为背景颜色设置动画.
$(function() {
$('.listing-2 li a').mouseover(function() {
$(this).animate({
backgroundColor: "#0e7796"
}, 'fast');
});
$('.listing-2 li a').mouseout(function() {
$(this).animate({
backgroundColor: "#d6f2c5"
}, 'fast');
});
});
Run Code Online (Sandbox Code Playgroud)
如何为边框颜色做同样的事情?
我开始编写一些JS代码,使变量值随着时间的推移而增加,达到目标值,并采用某种形式的"缓入".
我意识到jquery已经在它的.animate()方法中做到了这一点.当然,该方法用于操纵CSS属性,而不是一般变量.
我的问题是,是否可以做任何事情来破解它,以便该方法影响变量,而不是CSS属性?