想去做一个背景渐变效果,然后想着可以用animate去写

$('body').stop().animate({background:'url(xxx.jpg)'},800);

实际上想一想,jQuery好像完不成这么智能的工作,渐变显示背景图片。

$('body').css({
            "opacity": 0,
            "backgroundImage": "url(xxx.jpg)"
        }).stop().animate({
            "opacity": 1
        })

先把原本的图片透明度改成0,并且改好背景图片再通过animate属性把它渐变出来

Last modification:May 14, 2021
If you think my article is useful to you, please feel free to appreciate