Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在标记中的内容之前插入动态创建的div_Javascript_Html_Dom - Fatal编程技术网

Javascript 在标记中的内容之前插入动态创建的div

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

如果我有一些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 some text
document.body.insertBefore(jselem, document.body.firstChild);