Getting element by a custom attribute using JavaScript

前端 未结 7 1113
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 05:24

I have an XHTML page where each HTML element has a unique custom attribute, like this:

<
7条回答
  •  既然无缘
    2020-11-30 06:14

    Doing this with vanilla JavaScript will do the trick:

      const something = document.querySelectorAll('[data-something]')
    

提交回复
热议问题