In jQuery, how do I select elements between elements with certain classes?
jquery
Solution
$('li.foo').nextUntil('li.bar')
http://jsfiddle.net/zZRDB/1/
Problem
I have an unordered list. ``` <ul> <li class="foo">Baz</li> <li>Select Me!</li> <li>Select Me!</li> <li>Select Me!</li> <li class="bar">Baz</li> <li>Don't Select Me</li> <li>Red Herring List Item</li> </ul> ``` How do I select the list items in between the list items with classes foo and bar using jQuery? I do not know the contents of any list items. I also do not know how many list items are there to be selected so I cannot depend on a count.