• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change inline style with Javascript

 
Reese Doherty
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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');
}
else
{
alert('In else');
}
}

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

Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
contains is not a method that I know of: http://developer.mozilla.org/en/docs/JavaScript_Methods_Index#C

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic