How could i开发者_开发百科 select all the elements between two tags of the same type using javascript or jquery?
For examle if i had:
<h1></h1>
<h2><h2>
<li1></li1>
<li2></li3>
<li3></li4>
<h2></h2>
How could i get all the <li>
?
I tried using this $units=$(this).nextuntil("h2");
but it didn't work
$('h2:first').nextUntil('h2:last');
Demo: http://www.jsfiddle.net/4yUqL/63/
This of course only works in this particular example. In a more complex markup, you would probably need to be more specific. Like $('h2:eq(2)')
or others pseudo-selectors.
精彩评论