18910140161

HTML-如何使用javascript添加<div>-Stack溢出

顺晟科技

2022-10-19 11:25:26

33

是否可以使用JavaScript将HTML代码添加到HTML中。?

因为我有这段代码,所以它是这样自动生成的:

<div class="investi-announcements-summary" data-investi-date-format="dd MMM yyyy" data-investi-num-announcements="100" data-investi-filter-regex=".*presentation">
   <div>28 Jun 2021</div>
   <h4><a href="http://www.example.com" target="_blank">Investor Presentation - June 2021</a></h4>
</div>

并且我想在

之前和之后添加这段代码

如下所示:

<div class="investi-announcements-summary" data-investi-date-format="dd MMM yyyy" data-investi-num-announcements="100" data-investi-filter-regex=".*presentation">
   <div>28 Jun 2021</div>
   <h4><a href="http://www.example.com" target="_blank">Investor Presentation - June 2021</a></h4>
</div>

如果可能的话,我希望有人能帮我。

谢谢,


顺晟科技:

是的,有可能。在这个特定的示例中,您可以用新建的:

替换outer

但是您应该查看一些教程,说明如何添加/替换DOM元素

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航