以下代码应触发鼠标enter()和mouseleave()每个元素在找到的集合中,每个元素之间的间隔为2000毫秒。超时没有效果,直接到最后。
$(window).load(function(){
var delayslide = 0;
$(".featuredslider a").each(function(){
var current = $(this).index();
window.setTimeout(function(){
$(".featuredslider a").mouseleave();
$('.featuredslider a:eq(' + current + ')').mouseenter();
delayslide += 2000;
}, delayslide);
});
});
答案 0 :(得分:-1)
你走了:
var elems = $( 'a', '.featuredslider' ).get(),
i = -1;
(function loop() {
$( elems[i] ).mouseleave();
i += 1;
$( elems[i] ).mouseenter();
if ( i < elems.length ) { setTimeout( loop, 2000 ); }
})();