我创建了一个小交互,显示列表项,单击时旋转它们 - http://jsfiddle.net/S79qp/430/
我最近不得不将 .indexOf()
更改为 jQuery.inArray
,因为 .indexOf()
在 IE8 中不起作用。我遇到的问题是我无法让它工作,因为我不熟悉这种方法。有人可以告诉我我做错了什么
index = jQuery.inArray(a, current) + 1;
if (index < 0 || index >= l.length) {
index = 0;
}
next = (l.eq(index).html());
jQuery(this).html(next);
return this;
最佳答案
在你的inArray中,发送的参数顺序不正确。
应该是
index = jQuery.inArray(current,a) + 1;
这是(您正在寻找的值),(在哪里查找)
http://jsfiddle.net/S79qp/431/这是正确的 fiddle
关于javascript - 无法让 "jQuery.inArray"在我的代码中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16188103/