<html>
...
<body>
...
// element should be inserted here
</body>
</html>
我对原生JavaScript并不是很熟悉,一直在使用jQuery。到目前为止,我尝试了这个方法,但是它获取的是在<head>和<body>中间的元素。
var bodyTag = document.getElementsByTagName('body')[0];
bodyTag.parentNode.insertBefore(myElement, bodyTag);