S Singh
S Singh

Reputation: 1473

Extract all inline css of concernet html

I want to extract all inline styles of the concerned html.

For example, below is the concerned html for which inline css is to be extracted:

<div id="concernedHtmlPortion" style="style1">
    <div style="style2">
    <div style="style3;style4">Hello World!!</div>
    <div></div>
</div>

Is there any way to extract all style by using only root id="concernedHtmlPortion"?

Result of extraction should be: style1,style2,style3,style4

Any help please !!

Upvotes: 2

Views: 738

Answers (1)

gdoron
gdoron

Reputation: 150263

var allStyles = [];
$('#concernedHtmlPortion, #concernedHtmlPortion [style]').each(function() {
    allStyles.push($(this).attr('style').split(';'));
});
alert(allStyles);​

Working DEMO

Upvotes: 3

Related Questions