jquery: iterating through various ul's list-items?
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 we开发者_运维知识库re only one UL. http://jsfiddle.net/zBjrS/2/
any idea how i could do that?
thank you
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;
you could give each li an id with a number
<li id="item_1"></li>
<li id="item_2"></li>
store the number of the selected item somewhere and use it to build an id string to use as the selector
精彩评论