可能重复:
Special color transition effect with pure jQuery animation // no ui or other libary
我认为这段代码应该,但它不起作用。我可以告诉它正在改变颜色,但它不是褪色(就像CSS3过渡一样)。请帮忙。我的代码:
$(document).ready(function(){
$("#nav-wrap ul li a").mouseover(function(){
$(this).css("color","#444");
});
$("#nav-wrap ul li a").mouseout(function(){
$(this).css("color","#999");
});
});
答案 0 :(得分:2)
$(document).ready(function(){
$("#nav-wrap ul li a").hover(function(){
$(this).stop().animate({color:'#444'}, 300);
}, function () {
$(this).stop().animate({color:'#999'}, 100);
}
)}
});
此代码需要jQuery UI。
答案 1 :(得分:1)
你需要的是animate()
元素,而不仅仅是改变css中的颜色值。 Here是关于如何做的参考。