samedi 18 avril 2015

Get all CSS classes of a HTML element

I need 2 things: 1) Get all classes of a html element, not only directly declared classes but all classes of computed element.


2) Get all computed CSS style of a html element, i tried all example found on google and on this site but no work any. I need exactly same result of Google Chrome inspector > Computed on right window, see image belove.


inpsector google


For example:



<style>

div { width: 100%; }
.container #myid { color: red; text-decoration: none; }
.classA { opacity: 0.8; }

</style>


Html element:



<div class="container">
<div class="classA" id="myid"></div>
</div>


Javascript functions i need:



function getAllCSSclass(idElement) {
...
//return text or array (ex. "div" , ".container #myid" , "classA"
}
function getAllCSSstyle(idElement) {
...
//return text or array (ex. "width: 100%" , "color: red; text-decoration: none" , "opacity: 0.8"
}

Aucun commentaire:

Enregistrer un commentaire