传递self时对jquery each()索引进行jquery [英] jquery each() index when passed self

查看:88
本文介绍了传递self时对jquery each()索引进行jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在此循环的每次迭代期间访问元素索引.

I am trying to access the element index during each iteration of this loop.

$('.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($);

很显然,我不知道正确的方法.

Clearly I do not understand the right way to do this.

插件扩展程序im使用:
http://creativecouple.github.com/jquery-timing/examples/pause-cycle-on-hover.html

这里有一个小提琴,可以更好地将其分解:
http://jsfiddle.net/zGd8a/

Heres a fiddle that breaks this down better:
http://jsfiddle.net/zGd8a/

解决方案:
http://jsfiddle.net/zGd8a/8/

A solution:
http://jsfiddle.net/zGd8a/8/

推荐答案

jsFiddle演示

jsFiddle demo

$('.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($);

这篇关于传递self时对jquery each()索引进行jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆