Skip to content Skip to sidebar Skip to footer

Select All Elements In Between Two Tags Of The Same Type?

How could i select all the elements between two tags of the same type using javascript or jquery? For examle if i had:

Solution 1:

$('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.

Post a Comment for "Select All Elements In Between Two Tags Of The Same Type?"