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

前端 未结 10 919
时光取名叫无心
时光取名叫无心 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 05:10

    You can include a getElementsByClass function, or you can use a jQuery selector.

    UPDATE: The implementation mentioned by @Shog9 is probably better than that above.

提交回复
热议问题