我的意思是重置它,restarting
以便它重新启动时间,这样重新启动需要 3 秒。
我的代码是:
/* ********** Forside Slider ********** */
var slider_current_id = 1;
$(".slidermenu").live("click", function() {
var id = $(this).attr('data-id');
clearInterval(window.slider_timer);
window.slider_timer = setInterval(start_slider_timer(), 3000);
window.slider_current_id = parseInt(id, 10);
$('.slidermenu.currentone').animate({backgroundColor: '#FCFBFB'}, 'slow');
$('.slidermenu.currentone').removeClass("currentone");
$(this).animate({backgroundColor: '#f3f3f3'}, 'slow');
$(this).addClass("currentone");
$('#activeimage img.currentone').fadeOut('slow');
$('#activeimage img.currentone').removeClass("currentone");
$('#activeimage img[data-id='+id+']').fadeIn('slow');
$('#activeimage img[data-id='+id+']').addClass("currentone");
});
function start_slider_timer() {
if (window.slider_current_id == 5) {
window.slider_current_id = 1;
}else{
window.slider_current_id = window.slider_current_id + 1;
}
$('.slidermenu.currentone').animate({backgroundColor: '#FCFBFB'}, 'slow');
$('.slidermenu.currentone').removeClass("currentone");
$('.slidermenu[data-id='+window.slider_current_id+']').animate({backgroundColor: '#f3f3f3'}, 'slow');
$('.slidermenu[data-id='+window.slider_current_id+']').addClass("currentone");
$('#activeimage img.currentone').fadeOut('slow');
$('#activeimage img.currentone').removeClass("currentone");
$('#activeimage img[data-id='+window.slider_current_id+']').fadeIn('slow');
$('#activeimage img[data-id='+window.slider_current_id+']').addClass("currentone");
}
var slider_timer = setInterval(start_slider_timer(), 3000);
我没有收到任何错误,它只是没有运行.. 这是我的Interval
,根本没有运行。
希望有人能帮我解决这个问题。