我刚刚在我的网站上设置了一个Jquery图像旋转器,并想自定义它,以便图像在2秒内不会旋转。
我一直试图通过实现setTimeout函数(就在//循环遍历items注释的地方)来做到这一点,但它总是说我的函数没有声明,所以我假设tt在那个地方不能工作。
$(window).load(function() { //start after HTML, images have loaded
var InfiniteRotator = {
init: function() {
//initial fade-in time (in milliseconds)
var initialFadeIn = 0;
//interval between items (in milliseconds)
var itemInterval = 2000;
//cross-fade time (in milliseconds)
var fadeTime = 1000;
//count number of items
var numberOfItems = $('.rotating-left').length;
//set current item
var currentItem = 0;
//show first item
$('.rotating-left').eq(currentItem).fadeIn(initialFadeIn);
//loop through the items
var infiniteLoop = setInterval(function() {
$('.rotating-left').eq(currentItem).fadeOut(fadeTime);
if (currentItem == numberOfItems - 1) {
currentItem = 0;
} else {
currentItem++;
}
$('.rotating-left').eq(currentItem).fadeIn(fadeTime);
}, itemInterval);
}
};
InfiniteRotator.init();
});我正在使用此站点http://trendmedia.com/news/infinite-rotating-images-using-jquery-javascript/中的代码
发布于 2012-08-10 10:46:44
setTimeout(function(){
InfiniteRotator.init();
},2000);发布于 2012-08-10 10:53:15
重写最后一个结束括号:
});看起来好像有隐藏的字符。
https://stackoverflow.com/questions/11894610
复制相似问题