jQuery prev() and next()
I am using jQuery. I have HTML code which looks like this:
<ul>
<li>123</li>
<li id="hello">456</li>
</ul>
<ul>
<li>78开发者_开发问答9</li>
</ul>
I want, with jQuery, to get the li element after #hello (the 789 element). I tried with $('#hello').next()
, it does not work.
How do I do?
$('#hello').parent().next().children();
the
parent()
[docs] method to go up to the<ul>
elementthe
next()
[docs] method to go to the next<ul>
elementthe
children()
[docs] method to get the nested<li>
element
try something like
$('#hello').parent().next().children().eq(0)
http://api.jquery.com/category/traversing/tree-traversal/ might be useful
精彩评论