0
我已經示例標記以下jQuery的如何包裝多個標籤在一個DIV
<h2>Title 1</h2>
<input>
<input>
<h2>title 2</h2>
<input>
而且它需要輸入字段的下列
<div>
<h2>Title 1</h2>
<input>
<input>
</div>
<div>
<h2>title 2</h2>
<input>
</div>
的量是可變的,並且我可以在h2上設置一個類
我已經用.wrap()
和.wrapAll()
試過了,但是將每個元素包裝在一起或者每個元素分開。
有關類似問題的SO上的其他問題沒有變量輸入,可以使用next()或其他。
的div都需要在單獨的情況下手風琴,改變的東西
E: 到目前爲止: $('#id').nextUntil('.title').andSelf().wrapAll("<div class='hihi'></div>");
工程兩個要素之一。可能需要each()
?