我已尝试过循环等,但我只能运行此功能两次
function play() {
setInterval(function(){
var next = $(".furniture .active, .pets .active").next("img");
var i = 0;
var current = next.prev("img");
current.removeClass("active").addClass("current")
next.removeClass("current").addClass("active");
if (!next.length) {
next = $(".furniture img:first");
};
}
}, 3000);
}
play();
答案 0 :(得分:4)
你可能想要这样的东西:
function play(timeout) {
setTimeout(function() {
...
}, timeout);
}
play(3000);
play(6000);
答案 1 :(得分:1)
var counter = 0;
play();
function play()
{
counter = counter + 1;
var next = $(".furniture .active, .pets .active").next("img");
var i = 0;
var current = next.prev("img");
current.removeClass("active").addClass("current")
next.removeClass("current").addClass("active");
if (!next.length) {
next = $(".furniture img:first");
};
}
if (counter < 2)
{
setTimeout(play(), 3000);
}
}