[英]How to select text range within a contenteditable div that has no child nodes?
[英]removing child nodes within a DIV
我想刪除具有特定className的DIV的ChildNodes。
最好的方法是什么?
謝謝。
var myDiv = document.getElementById('my-div'),
children = myDiv.childNodes,
len = children.length,
reg = /(?:\s|^)fooClass(?:\s|$)/;
while (len--) {
if (reg.test(children[len].className || '')) {
myDiv.removeChild(children[len]);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.