jquery:迭代各种 ul 的列表项?
嘿伙计们, 有人已经帮助我解决了以下问题:我想用向上和向下箭头遍历列表项。 http://jsfiddle.net/zBjrS/1/ 在此示例中,我只有一个 UL,并且想要浏览其列表项。
与此同时,我在彼此下面有多个 ul,并且希望无缝地浏览所有这些 ul,就好像只有一个 UL 一样。 http://jsfiddle.net/zBjrS/2/
知道我该怎么做吗?
谢谢
hey guys,
someone already helped me solving the following problem: i wanted to iterate with my up and down arrows through list-items. http://jsfiddle.net/zBjrS/1/
in this example i only had one UL and wanted to navigate through its list-items.
meannwhile i have multiple ul's underneath each other and want to navigate seemlessly through all of them as if there were only one UL. http://jsfiddle.net/zBjrS/2/
any idea how i could do that?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要检查是否找到任何元素,如果没有,请尝试使用
.parent().prev().children(':first')
(或:last< /code> 向后退)。请参阅我对您的 jsfiddle 的更新;
You need to check whether any elements have been found, and if they have not, try using
.parent().prev().children(':first')
(or:last
for going backwards). See my update to your jsfiddle;你可以给每个 li 一个带有数字的 id,
将所选项目的编号存储在某处,并使用它来构建一个 id 字符串以用作选择器
you could give each li an id with a number
store the number of the selected item somewhere and use it to build an id string to use as the selector