0
我有点新的jQuery和需要一些帮助,我搜索了解决方案的网络,并试图编辑它,以满足我的要求。我想要的是更改背景事件,并且内容中还有一个滑块,当更改控件时,背景也会改变。我已经做到了,但我有2个问题:动画和重置间隔
- 我需要重新设置间隔时,其点击(现在它 混合起来)
- 我需要动画背景的变化insted的 变化的直接(或易于褪色)
这里是代码: -
$(window).load(function(){
var images = ['images/background/body-bg.jpg','images/background/body-bg2.jpg'];
var i = 0;
function changeBackground() {
$('html').css({
'background': function(){
if (i >= images.length) {
i=0;
}
return 'url(' + images[i++] + ')';
},
'background-position':'center',
'background-attachment':'fixed',
'background-size':'cover'
})
}
// Call it on the first time
changeBackground();
(function(){
$('.sliderControl > li').children().on('click', function(){
changeBackground();
window.clearInterval()
})
})();
// Set an interval to continue
setInterval(changeBackground, 5000);
});