This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 63351

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] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Change inline style with Javascript
It's not a secret anymore!