1

我完全不知道为什么背景颜色没有改变,我已经花了太多时间在它上面:

<input type="button" class="front-consultation-btn" value="Get A Free Consultation">

<script>
    $('.front-consultation-btn').animate({ backgroundColor: '#FF0000', width: 400 }, 500);
</script>

为什么这只改变宽度属性?

4

2 回答 2

2

这是因为jQuery默认不支持动画颜色,jQueryUI添加了这个功能:http: //jqueryui.com/demos/animate/

于 2012-08-14T19:25:10.050 回答
1

为什么不使用 CSS3?

.yourelement {
    background: #fff;
}

.yourelement:focus, .yourelement:hover {  
    -webkit-transition: background-color 0.5s linear;   
    background: #ccc;   
}  
于 2012-08-14T19:24:06.953 回答