JavaScript删除所有子元素

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/csdnlinyongsheng/article/details/83026443



    var div = document.getElementById("div1");
    while(div.hasChildNodes()) //当div下还存在子节点时 循环继续
    {
        div.removeChild(div.firstChild);
    }

猜你喜欢

转载自blog.csdn.net/csdnlinyongsheng/article/details/83026443