我一直试图让它工作,但似乎没有任何帮助。在我的jQuery为什么indexOf没有找到我的数组中的键?
所以我有两个图片都在图片数组。 我想要做的是,当你点击前一张照片时,下一张照片会出现。 我很确定问题在于indexOf
,因为它每次都返回-1。
如果我更换行:
pictures[listIndex+1].show("drop", {direction: "up"}, 1000);
< ---不工作。
符合:
pictures[1].show("drop", {direction: "up"}, 1000);
< ---它的工作原理,但不是非常有用的。
我希望你能理解我的问题是什么,对于我的坏英语感到抱歉。我非常感谢你的帮助。
$(document).ready(function(){
var pictures = [$("#link"), $("#italy1")];
pictures[1].hide();
$("#link").click(function(){
var listIndex = pictures.indexOf($(this));
pictures[listIndex+1].show("drop", {direction: "up"}, 1000);
});
$("#italy1").click(function(){
$(this).hide("drop", {direction: "up"}, 1000);
});
});
非常感谢您的快速回复。它现在就以我想要的方式工作 – 2013-04-20 17:11:23