我怎样才能找到没有ID的<div>
标签?删除没有ID的div元素
这是我的标记:
<body>
<div>this is a text</div>
</body>
这是用我的JavaScript来div
s添加到页面:
var show = function() {
var htmlNode = document.createElement('DIV');
document.body.insertBefore(htmlNode, document.body.childNodes[0]);
htmlNode.innerHTML = 'this is a text';
};
if (window.addEventListener) {
window.addEventListener("load", show, true);
} else {
}
window.attachEvent("onload", show);
我怎样才能删除此页面加载后?通过将JavaScript放在页面的底部?
可以覆盖显示()函数什么也不做。 –
您可以在页面加载时添加DIV。你想什么时候删除它? –
你可以检查以前的问题吗? [像这样](http://stackoverflow.com/questions/4253431/removing-a-div-with-no-id-or-class-with-javascript)? –