gpt4 book ai didi

jquery - 使用 jQuery 淡入背景颜色?

转载 作者:行者123 更新时间:2023-11-30 23:51:55 24 4
gpt4 key购买 nike

我想要一个 div 并让背景在鼠标进入时淡入白色,并在鼠标退出时淡出为黑色。关于如何在 jQuery 中执行此操作有什么想法吗?

最佳答案

使用 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-color(用于动画颜色)。 https://github.com/jquery/jquery-color/

关于jquery - 使用 jQuery 淡入背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19441806/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com