Is there a way to easily do nextUntil, so that the element matched by the selector is included? I have this, which is only fine if there is a previous sibling:
$("#content").find("h3:first").prev().nextUntil("ul:last").wrapAll("<div id='collapse'></div>");
Best Answer
Remove
.prev()
, replace.nextUntil
with.nextAll
and use.addBack()
at the end of your selector as shown below:Pre 1.8 should use
andSelf
instead ofaddBack