I'm trying to remove all jQuery from my code. Until now I used
if ($(selector).find(':focus').length === 0) {
// focus is outside of my element
} else {
// focus is inside my element
}
to distinguish wether the focus is inside of one of my elements. Can you show me a jQuery-free way of doing it?
ancestorElement:focus-within?Array.from(document.querySelectorAll(selector)).some(node => node.contains(document.activeElement))maybe.:focusor:focus-withinis better and easier.