我想采取一个div,并在mouseenter上将背景淡化为白色,并在mouseout上淡出为黑色。任何想法如何在jQuery中做到这一点?使用jQuery淡入淡出的背景色?
4
A
回答
10
与jQuery .hover()
$("div").hover(
function() {
$(this).animate({backgroundColor: "#fff"}, 'slow');
}, function() {
$(this).animate({backgroundColor:"#000"},'slow');
});
与jQuery .mouseover()
$("div")
.mouseover(function() {
$(this).animate({backgroundColor: "#fff"}, 'slow');
})
.mouseout(function() {
$(this).animate({backgroundColor:"#000"},'slow');
});
注意你必须使用jQuery的颜色(动画颜色)。 https://github.com/jquery/jquery-color/
2
您需要为使用jQuery UI libarary或jQuery Colors,使颜色
$('div').hover(function() {
$(this).stop(true, true).animate({
backgroundColor: 'black'
})
}, function() {
$(this).stop(true, true).animate({
backgroundColor: 'white'
})
})
演示动画制作:Fiddle
+0
@nrsharma固定....用于测试目的jQuery用户界面移除 –
0
OP要求的jQuery。对于那些试图徒手没有jQuery的:
<div id="x" style="background-color:rgb(255,255,105)">hello world</div>
<script type="text/javascript">
var unBlue=100;
var gEvent=setInterval("toWhite();", 100);
function toWhite(){
if(unBlue<255) document.getElementById("x").style.backgroundColor="rgb(255,255,"+unBlue+")";
else clearInterval(gEvent);
unBlue+=10;
}
</script>
相关问题
- 1. jQuery在背景颜色淡入淡出
- 2. CSS背景淡入淡出使用jquery
- 3. jquery淡入淡出div中的背景图像 - 淡入淡出
- 4. 如何使用jQuery淡入淡出背景色?
- 5. 背景图像淡入淡出与jQuery
- 6. JQuery - 淡入淡出新背景图片?
- 7. jquery淡入淡出渐变背景
- 8. 背景淡入淡出
- 9. 背景淡入淡出
- 10. 淡入淡出的背景图像(不是正文或淡出背景颜色)
- 11. jQuery的淡入淡出的CSS背景图像和颜色
- 12. jQuery淡入淡出的标题栏的背景颜色
- 13. 如何使用Swift淡入/淡出tableviewcell的背景色
- 14. 淡入/淡出背景图像没有白色背景
- 15. 复选框淡入/淡出背景颜色-jquery
- 16. Jquery背景/文本颜色淡入淡出
- 17. 淡入淡出背景色jquery a:悬停
- 18. 淡入淡出背景图像淡入淡出div内容
- 19. 添加背景的淡入淡出效果改变使用jQuery
- 20. 交叉淡入淡出使用jQuery的背景图像
- 21. 淡出的背景颜色与jQuery
- 22. 淡入淡出中的背景图像
- 23. 如何使用jquery淡入淡出背景图像
- 24. 使用jquery连续淡入淡出背景图像
- 25. 使用jQuery淡入淡出背景图片
- 26. 如何使背景图像从灰度淡入淡出颜色?
- 27. jquery淡出表格背景颜色
- 28. jquery的DIV背景淡入
- 29. 淡入淡出图像到背景
- 30. 在背景图像中淡入淡出
看到http://api.jquery.com/hover/ –