Finding Element That Doesn't Have a Hidden Parent?

Viewed 17

I have a few elements that match a selector and have parents which are toggled between display:none and no style. I'd like to select the first visible one using a CSS selector.

Ex: in this JSFiddle I'd like my selector in the JS portion to pick div C rather than div A.

const found = document.querySelector(".find-me"); // .find-me:has(not(display=none)?
console.log(found.innerText);

Is there anyway to do this?

0 Answers
Related