niks
niks

Reputation: 554

Getting color parameter value of style attribute for all html element using javascript

I'm working on a iPhone project in which I want to change color theme for a given html template.

I want to get an array with color parameter values of style attribute for all tags.

Is there any efficient way to achieve it?

Note: elements in my template does not have id attribute. Also cannot use jquery as is not supported by iOS webview.

Upvotes: 0

Views: 229

Answers (2)

Sridhar R
Sridhar R

Reputation: 20418

Try This

var colorarr=[];
$("*").each(function(){
    colorArray.push($(this).css('color'));
   });
 console.log(colorArray);

Fiddle

Upvotes: 1

SW4
SW4

Reputation: 71150

If you use jQuery, this can be achieved thus:

var colorArray=[];
$('body *').each(function(){
    colorArray.push(this.css('color'));
});

Upvotes: 0

Related Questions