我试图在此循环的每次迭代中访问元素索引。
$('.slide').hide().repeat().each($).fadeIn($).wait(1000, function(){
//do stuff
}).wait(noHover).fadeOut($);
我试过做类似的事情:
$('.slide').hide().repeat().each(i, $).fadeIn($).wait(1000, function(){
alert(i);
}).wait(noHover).fadeOut($);
显然我不明白这样做的正确方法。
我使用的插件扩展:
http://creativecouple.github.com/jquery-timing/examples/pause-cycle-on-hover.html
这是一个更好地分解它的 fiddle :
http://jsfiddle.net/zGd8a/
最佳答案
$('.slide').hide().repeat().each($).fadeIn($).wait(1000, function(){
var idx = $(this).index(); // here you go!
$('body').append(idx); //here i need access to index number of element
}).wait(noHover).fadeOut($);
关于javascript - 通过 self 时jquery each()索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13002674/