javascript - 如何使用 JS 从 HTML 中删除特定标签?
问题描述
<figure>
<p>Hello please remove parent figure tag. I just want the this child p tag.</p>
</figure>
解决方案
这是针对您的问题的纯 Javascript 解决方案:
<html>
<body>
<figure id='x'><p id='y'>Hello</p></figure>
<script type='text/javascript'>
let a = document.getElementById('x').innerHTML;
document.getElementById('x').remove();
document.write(a);
</script>
</body>
</html>