Jquery将父代替换为第一个子代

Jquery将父代替换为第一个子代,jquery,jquery-selectors,Jquery,Jquery Selectors,我正在尝试将dom父对象替换为其第一个子对象,并删除所有其他子对象。它不起作用了。我收到错误:“无法在层次结构中的指定点插入节点” 此未引用#over1元素。相反,你应该: $("#over1").replaceWith(function() { return $(':first', this); }); $("#over1").replaceWith(function() { return $(':first', this); });

我正在尝试将dom父对象替换为其第一个子对象,并删除所有其他子对象。它不起作用了。我收到错误:“无法在层次结构中的指定点插入节点”


未引用#over1元素。相反,你应该:

$("#over1").replaceWith(function() { return $(':first', this); });
$("#over1").replaceWith(function() { return $(':first', this); });