(Javascript)在特定位置动态插入元素 [英] (Javascript) Inserting elements dynamically in a specific position
本文介绍了(Javascript)在特定位置动态插入元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上我是这样的:
<body>
<div class="class1">
</div>
<div class="class2">
</div>
<div class="class3">
</div>
...
</body>
我不知道为什么网站创建者使用类而不是ID(它们是唯一的),但是这并不重要,因为我正在编写一个GM脚本,所以getElementsByClassName('')[0]有效地做同样的事情。
I have no idea why the site creator used classes instead of IDs (they're unique), but it doesn't really matter as I'm writing a GM script and so getElementsByClassName('')[0] effectively does the same thing.
如何插入元素在第一和第二个div之间?
How can I insert an element between the first and second div?
推荐答案
创建自己的 insertAfter 函数
这篇关于(Javascript)在特定位置动态插入元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文