Get elements by attribute when querySelectorAll is not available without using libraries?

后端 未结 8 977
半阙折子戏
半阙折子戏 2020-11-22 11:27

How can you do the equivalent to

document.querySelectorAll(\'[data-foo]\')

where query

8条回答
  •  梦谈多话
    2020-11-22 12:09

    Try this it works

    document.querySelector('[attribute="value"]')

    example :

    document.querySelector('[role="button"]')
    

提交回复
热议问题