File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Change inline style with Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Change inline style with Javascript" Watch "Change inline style with Javascript" New topic

Change inline style with Javascript

Reese Doherty

Joined: Dec 07, 2006
Posts: 8
I am truing to change the online style of all elements on a page with the following javascript

el = document.getElementsByTagName('*');
for (i=0; i<el.length; i++)
if(contains(el[i].style.cssText, 'xxx'))
alert('In if');
alert('In else');

However I am getting an Object expected JS error. Anyone have any idea what I am doing wrong?

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
contains is not a method that I know of:

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Reese, your code will be easier to read if you use UBB code tags. Please read this for more information.
[ April 26, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Change inline style with Javascript
It's not a secret anymore!