我想選擇所有元素,除了第一個div在該類中。jquery:not(:first-child)wrapAll()each div
當前HTML:
<div class="cpt-cv-content-item">
<a>...</a>
<h4>...</h4>
...
</div>
<div class="cpt-cv-content-item">
<a>...</a>
<h4>...</h4>
...
</div>
我試着用保鮮所有:
$(".pt-cv-content-item :not(:first-child)").wrapAll("<div class='new'></div>");
此功能正確選擇除首先元素,但移動所有的人都進入第一個div。
我想是這樣的:
<div class="cpt-cv-content-item">
<a>...</a>
<div class='new'>
<h4>...</h4>
...
</div>
</div>
<div class="cpt-cv-content-item">
<a>...</a>
<div class='new'>
<h4>...</h4>
...
</div>
</div>
不幸的是我不能編輯HTML。 謝謝您提前
換行功能包裝每個選定的元素,反正謝謝 –