【发布时间】:2011-11-29 12:15:37
【问题描述】:
我想从<H2> 的开头到下一个<H2> 包装<div>,但它只是从第一段开始。
这就是我所拥有的,几乎可以完成这项工作:
$('h2:contains("test")').nextUntil('h2').wrapAll('<div class="wrapper" />');
这是我的 HTML:
/* from here */
<h2 class='test'>Include this in the wrap</h2>
<p>this</p>
<p>and this</p>
<p>and this</p> /* to here */
<h2 class='next'>before this</h2>
【问题讨论】:
标签: jquery-selectors dom-traversal