如何使用jquery添加父标记
我现在的代码是如何使用jquery添加父标记,jquery,html,Jquery,Html,我现在的代码是 儿童1内容 儿童2内容 儿童3内容 我希望使用jquery实现这样的功能 儿童1内容 儿童2内容 儿童3内容 如何做到这一点?$('#parent').children().not(':first').wrapAll(''); $('#parent').children().not(':first').wrapAll('<div id="newparent"/>'); 另一种方法 $(“#父”).children(“:gt(0)”).wrapAll(”)
儿童1内容
儿童2内容
儿童3内容
我希望使用jquery实现这样的功能
儿童1内容
儿童2内容
儿童3内容
如何做到这一点?$('#parent').children().not(':first').wrapAll('');
$('#parent').children().not(':first').wrapAll('<div id="newparent"/>');
另一种方法
$(“#父”).children(“:gt(0)”).wrapAll(”);
<div id="parent">
<div class="child1">Child 1 Contents</div>
<div id="newparent">
<div class="child2">Child 2 Contents</div>
<div class="child3">Child 3 Contents</div>
</div>
</div>
$('#parent').children().not(':first').wrapAll('<div id="newparent"/>');
$('#parent').children(':gt(0)').wrapAll('<div id="newparent"/>');