javascript - 如何使用 JS 从 HTML 中删除特定标签?

标签 javascript

<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>

关于javascript - 如何使用 JS 从 HTML 中删除特定标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61072276/

相关文章:

javascript - 如何搜索嵌套级别的 JSON 数组

javascript - 如何为数据库中的不同记录/行创建用户生成的链接列表,单击后填充 html 表单?

javascript - 在循环中使用 promise 的 node js,mongodb 中没有得到结果

javascript - 脚本 70 : Permission denied when adding options to select element from a recently closed iframe

javascript - CSS 样式为空

javascript - LocalStorage.getItem : Check if a key exists

javascript - wheelnav.js 弹跳效果

javascript - 按接近度对坐标(纬度和经度)结果进行排序

javascript - Flash Pro CC HTML5 Canvas & CreateJS - 如何将 lib 文件更新到最新版本?

javascript - Angular ng-sortable - 它如何工作的基本示例