File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Dynamically changing class Attribute 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 "Dynamically changing class Attribute" Watch "Dynamically changing class Attribute" New topic
Author

Dynamically changing class Attribute

ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

Hi,

I am facing problem while updating css class definition dynamically on some condition.


For Internet Explorer:


For Mozilla:



Because there are 36 'span' elements & I want to affect only 15 out of them which have attribute class set to 'myclass'.
These spans have ids wiz ('message1', 'message2',... 'message15'). I want to avoid code duplication & want to reuse the code at different places for varying number of spans so using for loop will become a complicated issue. please help me.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Seems like it'd make more sense to have separate CSS files.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Correct, you don't change the class itself, you assign a new class to the element.

Bear in mind that add and removing classes fro an element can also be a challenge because multiple classes are stored on an element as a space-delimited list.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

ramnna jain wrote:These spans have ids wiz ('message1', 'message2',... 'message15').


"wiz"? What is "wiz"?
ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

Thank you Bear, David... the information helped me to solve the problem.

I used 'wiz' to say 'for example' but I will not use it again...

Thank you..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically changing class Attribute