Get All Elements in an HTML document with a specific CSS Class

前端 未结 10 915
时光取名叫无心
时光取名叫无心 2020-12-01 04:10

What\'s the best way to get an array of all elements in an html document with a specific CSS class using javascript?

No javascript frameworks like jQuery allowed her

10条回答
  •  孤独总比滥情好
    2020-12-01 04:51

    If you want to do something for all the element with same id in a document. Although simple but sometime mind dont give green signals

    var x = document.getElementById(elementid);
    while(x){
    document.removechild(x);
    x = document.getElementById(elementid);
    }
    

提交回复
热议问题