<body>
<div id="J_APP_Wrapper">
<div class="" recharge="true">1</div>
<div class="" recharge="true">2</div>
<div class="" recharge="true">3</div>
<div class="live-wrapper">4</div>
</div>
<script type="text/javascript">
window.onload = function() {
remove()
}
// 删除节点
function remove() {
var removeNode = document.getElementById("J_APP_Wrapper");
var removeNodeL = removeNode.children;
console.log(removeNodeL)
for (var i = 0; i < removeNodeL.length; i++) {
if (removeNodeL[i].className != "live-wrapper") {
removeNode.removeChild(removeNodeL[i])
}
// if (removeNodeL[i].getAttribute("recharge") == "true") {
// removeNode.removeChild(removeNodeL[i])
// };
};
}
</script>
</body>
问题是 按照我的逻辑我是删除className != "J_APP_Wrapper"
的节点
但是 结果是出现2和4 ,
希望寻求帮忙 告知原因
如图
尚方宝剑之说
相关分类