Javascript 在标记中的内容之前插入动态创建的div
如果我有一些HTML文档的主体,如下所示:Javascript 在标记中的内容之前插入动态创建的div,javascript,html,dom,Javascript,Html,Dom,如果我有一些HTML文档的主体,如下所示: <body> <p>Here's some text</p> </body> 在动态创建div之后,是否有方法生成以下结果 Some other text here Here's some text 我想你是在问DOM方法 演示:我想你是在问DOM方法 演示: Here's some text Some other text here Some other text here Here's
<body>
<p>Here's some text</p>
</body>
在动态创建div
之后,是否有方法生成以下结果
Some other text here
Here's some text
我想你是在问DOM方法
演示:我想你是在问DOM方法 演示:
Here's some text
Some other text here
Some other text here
Here's some text
document.body.insertBefore(jselem, document.body.firstChild);