-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
  • 413
  • 2
  • 4
  • 8

1 Answers1

2

Add brackets

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