for(var i=content.childNodes.length-1;i>=0;i--){ var childNode=content.childNodes[i] content.removeChild(childNode) }
?for(var i=content.childNodes.length-1;i>=0;i--){
? ? ? ?var childNode=content.childNodes[i]
? ? ? ?content.removeChild(childNode)
? }
是什么意思
2015-11-27
1. 刪除該節(jié)點(diǎn)的內(nèi)容,先要獲取子節(jié)點(diǎn)的總數(shù)。
2. 然后使用循環(huán)遍歷每個(gè)子節(jié)點(diǎn)。
3. 使用removeChild()刪除節(jié)點(diǎn)。