Can';不要让Jquery颜色UI在悬停状态下工作

Can';不要让Jquery颜色UI在悬停状态下工作,jquery,jquery-animate,Jquery,Jquery Animate,我是jquery新手,我希望在悬停事件中更改a标记的背景颜色 到目前为止,这是我所拥有的,我无法得到的是回应 <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.animate-colors-min.js"></script> <script type="text/javas

我是jquery新手,我希望在悬停事件中更改a标记的背景颜色

到目前为止,这是我所拥有的,我无法得到的是回应

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.animate-colors-min.js"></script>

<script type="text/javascript">

$(document).ready(function() {
$(".form_layout_button_box a").hover(
    function(){
            $(this).animate({backgroundColor: '#D8E4BC'},'slow')
    },
    function() {
            $(this).animate({backgroundColor: '#C4D79B'},'slow')
    });
});
</script>

$(文档).ready(函数(){
$(“.form\u layout\u button\u box a”)。悬停(
函数(){
$(this.animate({backgroundColor:'#D8E4BC'},'slow'))
},
函数(){
$(this.animate({backgroundColor:'#C4D79B'},'slow'))
});
});
您需要使用将CSS属性应用于元素。至于动画,您可以尝试使用和

使用鼠标悬停,颜色将保留在鼠标上。所以我更喜欢使用mouseover和mouseout。如果要使用.hover(),还可以执行一些if/else逻辑

-或-

$(".form_layout_button_box a").mouseover(function(){
     $(this).css('background-color', '#D8E4BC');
});


$(".form_layout_button_box a").mouseout(function(){
     $(this).css('background-color', '#333');
});
使用鼠标盖和鼠标出的演示:

相当于CSS中的这一点:

这对纯CSS也有同样的影响

.form_layout_button_box a       {background-color:#666;}
.form_layout_button_box a:hover {background-color:#D8E4BC;}

我发现了我的错误,我没有正确地调用查询

我写过:

 function(){
        $(this).animate({backgroundColor: '#D8E4BC'},'slow')
},
在上面的示例中,我需要将$(this)替换为$($(this)),函数将正常工作

function(){
       $($(this)).animate({backgroundColor: '#C4D79B'},'fast')
},
谢谢你的建议

function(){
       $($(this)).animate({backgroundColor: '#C4D79B'},'fast')
},