我正在尝试将标题的背景淡入,white
但是当我尝试使用一些 jQuery 为背景颜色的淡化设置动画时,它就不起作用了。
jQuery
var windw = this;
$.fn.followTo = function ( pos ) {
var $this = this,
$window = $(windw);
$window.scroll(function(e){
if ($window.scrollTop() > pos) {
$this.animate({'backgroundColor':'rgba(255,255,255,1)'},400);
console.log($this.css('backgroundColor'));
console.log(pos);
} else if ($window.scrollTop() == 0) {
$this.animate({'backgroundColor':'rgba(255,255,255,0)'});
console.log($this.css('backgroundColor'));
console.log(pos + ' at the top');
} else {
$this.animate({'backgroundColor':'rgba(255,255,255,0)'});
console.log($this.css('backgroundColor'));
}
});
};
$('.home-header-main').followTo(86);
帮助表示赞赏