如何将内容包装在 jQuery 元素中,直到特定元素,如本例所示:
<div>
<span>
wrap this element
</span>
text to wrap
<span class='dont-wrap'>
dont wrap this
</span>
</div>
到:
<div>
<span>
<span>
wrap this element
</span>
text to wrap
</span>
<span class='dont-wrap'>
dont wrap this
</span>
</div>
我试过:
$('div).contents().nextUntil('.dont-wrap').wrap('<span/>');