我想找到某個div內的所有類和ID!和這些CSS屬性!如何查找某個div內的所有css類及其css屬性?
例子:
<div class="demo">
<div class="new_class">
<p id="para">This is Demo Paragraph</p>
<a style="background:#ccc">HyperLink</a>
</div>
</div>
<style>
.demo{
height:100px; width:100px; background:#FF0;
}
.new_class{height:40px; width:40px; background:#999;}
#para{color:#E1E1E1;}
</style>
現在的問題是:我想找到這些演示類內部使用的所有class和id!和他們的css值(現在應用哪種風格)。 我想找到如下結果:
<style>
.demo{
height:100px; width:100px; background:#FF0;
}
.new_class{height:40px; width:40px; background:#999;}
#para{color:#E1E1E1;}
a{background:#ccc;}
</style>
到目前爲止你做了什麼嘗試? – 2014-10-17 05:06:40
使用$(「。demo」)。children(),然後遍歷所有來檢索個人ID,類和樣式屬性。但是,所有的輸出結果都是使用javascript,而不是您期望的樣式標籤。此外,您將無法區分內聯樣式和其他樣式。 – 2014-10-17 05:07:02