Is there a way to check if a CSS selector ( obtained by document.styleSheets[666].rules[1984].selectorText ) matches a specific element ?
I am asking for a cross browser pure javascript solution, but i will consider using jQuery if it is simply done in it.
For modern browsers, there’s
matchesSelector. For less modern browsers, you can usequerySelectorAlland walk the DOM.Don’t use jQuery. Sizzle is enough.
https://github.com/jquery/sizzle/wiki/Sizzle-Documentation