如何删除包装器(父)而不删除子 [英] how can I remove wrapper (parent) without removing the child
本文介绍了如何删除包装器(父)而不删除子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除父母而不删除孩子 - 这是可能的吗?
html结构:
I would like to remove parent without removing the child - is this possible? html structure:
<div class="wrapper">
<img src"">
</div>
<div class="button">Remove wrapper</div>
点击按钮后,我想要:
<img src"">
<div class="button">Remove wrppper</div>
推荐答案
可以使用这个API: http://api.jquery.com/unwrap/
Could use this API: http://api.jquery.com/unwrap/
.unwrap
代码将看起来像这样:
示例代码
$('.button').click(function(){
$('.wrapper img').unwrap();
});
这篇关于如何删除包装器(父)而不删除子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文