This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change inline style with Javascript  RSS feed

 
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
Posts: 66142
141
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!