How to get all DEFINED CSS Selectors for a given DOM Element using jQuery?
With defined I mean all CSS Selectors which are used in any of the Stylesheets applied to the document.
In a way, this is similar to the feature implemented by FireBug where in it shows all the Applied CSS Selectors for a selected DOM Element.
Any help is appreciated.
From this answer you might be able to get what you are looking for by looping through the cssRules property.
Given the following dom:
And css rules:
We would get a matched rule set of:
Example on jsfiddle. Not sure how well this will work for all scenarios but might be something to look at if it will fit your needs.
Updated with a slightly more complete example…