0

I want to pull only the ones with flex display out of 10 child elements

document.querySelectorAll('.DOMDivCont[display="flex"]')

When I try this it returns empty array

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
Swifty
  • 11
  • 2

1 Answers1

0

This is only possible if the element has a inline display=flex, but you want to select by style

document.querySelectorAll('.DOMDivCont[style*="disyplay: flex"]')

so you get every DOMDivCont with inline style that contains flex

But the downsites are

  1. it will also find flex-inline etc
  2. its not working if you write it like "disyplay:flex"
  3. its only for inline styles

If you want to select them by computed styles, then you have to do something like

document.querySelectorAll('.DOMDivCont').forEach(element => {
  console.log(getComputedStyle(element).display);
})
Zokki
  • 125
  • 1
  • 8