js刪除特定節點
阿新 • • 發佈:2018-11-03
直接上程式碼
function clear(){ var head = document.getElementsByTagName('head')[0].children; for(var i=0;i<head.length; i++){ if(head[i].innerHTML){ if(head[i].innerHTML.indexOf("NREUM") > 0){ document.getElementsByTagName("head")[0].removeChild(head[i]); } } } var body = document.getElementsByTagName('body')[0].children; for(var j=0;j<body.length; j++){ if(body[j].innerHTML){ if(body[j].innerHTML.indexOf("NREUM") > 0){ document.getElementsByTagName("body")[0].removeChild(body[j]); } } } } setTimeout(clear,5000);
尋找head和body中含有NERUM在節點,並刪除
qq:274501366