• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Can javascript modify CSS classes?

 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Say I have a bunch of tags that use a certain CSS class. Can I through javascript simply change a property of that class and have it effect all those HTML elements? If that's impossible, then could I quickly get a collection of all HTML elements that share a certain property value (not tag name) short of recursively looping through every single element in a document and calling getAttribute on it?

Thank you,
Yuriy
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess getElementsByName would work, if it's not too slow when the page has thousands of elements.

-Yuriy
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, getElementsByName won't work since the elements I need it to work with don't support an innate name property. According to the msdn online library the method also works with id's, but apparently that's only IE's implementation since it doesn't work in Firefox.

-Yuriy
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Racked my brain few a few seconds...





[edit-ugly format removed]
Eric
[ April 07, 2005: Message edited by: Eric Pascarello ]
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, thanks Eric!

Yuriy
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think changing css rules is well dcumented anywhere....

(I did not look too hard)

Eric
 
Good night. Drive safely. Here's a tiny ad for the road:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!