Removing HTMLCollection elements from the DOM

前端 未结 5 1057
孤独总比滥情好
孤独总比滥情好 2020-11-28 12:53

I have a collection of paragraph elements. Some are empty and some contain whitespace only, while others have content:

Pellentesque habitant morbi t

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 13:35

    In my case this was my solution:

    var temp = document.getElementsByClassName('level-size');
    for (var i = 0, len = temp.length; i < len; i++)
        temp[0].remove();
    

    temp[0] because each time I remove it, the hole table is pushed back one index.

提交回复
热议问题