Javascript jquery.wrap()的HierarchyRequestError
我无法理解为什么我在chrome中出现这个错误:Javascript jquery.wrap()的HierarchyRequestError,javascript,jquery,Javascript,Jquery,我无法理解为什么我在chrome中出现这个错误: Uncaught HierarchyRequestError: Failed to execute 'replaceChild' on 'Node': The new child element contains the parent. 在firefox中也一样: HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy 这是
Uncaught HierarchyRequestError: Failed to execute 'replaceChild' on 'Node': The new child element contains the parent.
在firefox中也一样:
HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy
这是我的js:
// Applies wrapper to lists
$('#content .portlet-body').find('ul').each(function() {
var content = $(this);
if ( !content.hasClass('dropdown-menu') && !content.hasClass('nav') && !content.hasClass('lfr-discussion-actions') && !content.hasClass('tree-view-content') ) {
content.wrap('<div class="floating-list"></div>');
}
});
//将包装器应用于列表
$('#content.portlet body').find('ul').each(function(){
var content=$(此值);
如果(!content.hasClass('dropdown-menu')&&&!content.hasClass('nav')&!content.hasClass('lfr-discussion-actions')&&&!content.hasClass('tree-view-content')){
content.wrap(“”);
}
});
这段代码的目的是在具有特殊类的包装器div之间包装特定的ul
列表。有什么想法吗
谢谢无法复制;代码在这里运行良好:您确定这是引发错误的块吗?当我将代码放入注释中时,错误消失。所以我相信就是这样。我还有其他代码。但是没有使用任何
replace
、或clone
或wrap
功能。一些人使用了appendTo
和append
,但乍一看em并没有什么问题。