【发布时间】:2010-01-09 04:40:01
【问题描述】:
我有一个 div #someDiv,我可以创建一个新元素并使 #someDiv 成为它的子元素吗?基本上我想在#someDiv 周围包装一个新元素。我该怎么做?
$("#someDiv").appendTo($("<div id='newParent'></div>"));
// The intent is to move #someDiv into the new container
// The new container may or may not be in the same
// position in the DOM as #someDiv
感谢您的任何提示!
干杯, ~ck 在圣地亚哥
【问题讨论】:
-
上面的代码有错误吗?
-
不。不是语法上的,最少的。
标签: javascript jquery html