• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically changing class Attribute

 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like it'd make more sense to have separate CSS files.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64992
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64992
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ramnna jain wrote:These spans have ids wiz ('message1', 'message2',... 'message15').


"wiz"? What is "wiz"?
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic