It's a little hard to explain what I want to do, So I'll try to do it with an example. Lets say I have this HTML:
<ul>
<li id="myli" class="myclass">Hello</li>
</ul>
and the following css
.myclass{
color:red;
}
li.myclass{
background-color:black;
}
ul li{
float:left;
}
Now, I want to create a function in JS that get a DomElement and gets all the matching selectors from the css files for this element (like the F12 toolbar in chrome that shows all styles for an element) like the following:
var mySelectors = GetSelectorsForElement(document.getElementById("myli"));
and the content of mySelectors will be
[".myclass",
"li.myclass",
"ul li"]
Can this be achieved in JS?