0

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.

3
  • 2
    Why would you want to do that instead of applying appropriate CSS? Commented Nov 13, 2013 at 10:26
  • It would be far easier to create multiple stylesheet then have the stylesheet switch option - Google stylesheet switcher - tons of examples out there. Commented Nov 13, 2013 at 10:27
  • Jquerry works when you call it in a proper way, like, <link rel="stylesheet" href="jquery.mobile-1.1.0.min.css" /> <script src="jquery-1.7.2.min.js"></script> <script src="jquery.mobile-1.1.0.min.js"></script> instead of <link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" /> <script src="js/jquery-1.7.2.min.js"></script> <script src="js/jquery.mobile-1.1.0.min.js"></script> Commented Nov 13, 2013 at 10:38

2 Answers 2

1

Try This

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

Fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Sridhar...can you tell me how to retrieve only those element color value who have color parameter in style attribute i.e for now it is returning rgb(0,0,0) default value for those element which does not have color parameter
0

If you use jQuery, this can be achieved thus:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.