-3

I have a div that only contains data attribute, I want to select it from console with javascript

<div data-contents="true">

I tried document.querySelectorAll('div > data-contents="true"')

Doesn't work

Pingo
  • 303
  • 3
  • 8

1 Answers1

2

Add brackets

document.querySelectorAll('[data-contents="true"]')
Achraf
  • 1,194
  • 7
  • 14