<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
标签 javascript jquery html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 8 年前。
我在 ul li 中有如下内容:
<ul>
<li>Content 1 Detail</li>
<li>Content 2 Detail</li>
<li>Content 2 Detail</li>
</ul>
现在我想在单击下一步按钮时显示 content 2
等等。我试过 JSFiddle但其中的反向链接不起作用。
请帮帮我。
最佳答案
首先,在下一个和上一个函数中,它不应该是 .appendTo('ul')
因为它会复制 li
(检查 DOM)。请改用 .appendTo($(this).parent()
。
此外,它不起作用的原因是因为您在 fadeOut()
回调中使用了 $(this).parent('.container')
。但在该回调中,this === li
并且它没有父级 .container
。
然而,您只能使用不带参数的 .parent()
并且它有效:http://jsfiddle.net/zYnYM/27/
关于javascript - 使用下一个和上一个按钮循环遍历 li 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26554354/