我找不到像使用 jQuery 那样打开元素的替代函数。 还有其他方法可以做到这一点吗?
我的目标是存档此代码并将其所有属性复制到其子元素。 并删除父级。
<div class="abc" myid="123" position="2">
<span class="someblock">
<p>Some paragraph</p>
<img width="140px; height: 140px;" class="myimg" src="http://www.urltoimage.com/image.png">
</span>
</div>
结果应该是:
<span class="someblock abc" myid="123" position="2">
<p>Some paragraph</p>
<img width="140px; height: 140px;" class="myimg" src="http://www.urltoimage.com/image.png" />
</span>
提前致谢,克里斯。
最佳答案
我总是使用 jQuery 发送我的 ExtJS 项目来执行此类操作,我建议您也这样做
它会让你的生活更轻松;)
编辑:
如果您严格需要在 ExtJS 中执行此操作,您将需要 Ext.dom.Element
并对其进行操作。 Ext.get('id')
将为您提供一个。
unwrap: function() {
parent = this.parent().dom;
this.insertBefore(parent );
// code for copy the styles, classes & attributes here
parent.destroy();
return this;
}
The method is supposed to be called on
Ext.dom.Element
class or any one that extend it
关于javascript - Ext JS 中是否有其他方法,例如 jQuery .unwrap 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17210024/