【发布时间】:2017-04-28 05:02:15
【问题描述】:
我一直在尝试使用 jquery 的 animate(0 方法更改 jumbotron 的颜色,但由于某种原因它不起作用。
$('.jumbotron').on('click', function() {
console.log('click');
$('.jumbotron').animate({
backgroundColor: "rgb(229, 76, 76)"
}, 1000);
$('body').animate({
backgroundColor: "#ff7373"
}, 1000);
});
仅当我使用 css 选择器更改颜色时才有效。像这样,
$('#jumbo').on('click', function() {
$( this ).css('background-color','#e54c4c');
});
有人知道为什么吗?
【问题讨论】:
-
$('.jumbotron').animate({ background-color: "rgb(229, 76, 76)" }, 1000); $('body').animate({ background-color: "#ff7373" }, 1000);试试这个 -
还是不行。 @AlivetoDie
标签: jquery html css twitter-bootstrap-3 jquery-animate