I\'m really struggling to see how to do this. I want to check if a class exsits somewhere in one of the parent elements of an element.
I don\'t want to use any libra
You can use some and contains to achieve the result:
some
contains
function hasParentWithMatchingSelector (target, selector) { return [...document.querySelectorAll(selector)].some(el => el !== target && el.contains(target) ) } // usage hasParentWithMatchingSelector(myElement, '.some-class-name');