View Full Version : Change the value in a CSS function
Ultragames
11-15-2005, 06:07 AM
I want to change the value of the CSS function, rather than changing the style attribute of every element that uses that class.
Can i do this without switching CSS files?
PhotoJoe47
11-15-2005, 06:40 AM
I want to change the value of the CSS function, rather than changing the style attribute of every element that uses that class.
Can i do this without switching CSS files?
What is a CSS function?
You can do inline style changes. What is it that you want to do?
Also this might be a question for the CSS forum unless you are wanting to use javascript in conjuntion with the CSS style change.
Ultragames
11-15-2005, 06:51 AM
Let me explain better.
<td class="MyClass">stuff</td>
I want to change the values inside MyClass. Here is why:
I could do something like:
[the td id].className = "NewClass";
or:
[the td id].style.property = "something";
However this requires me going through every td that uses MyClass either by ID or Node. This is too heavy on the client for the ammount of changes im looking at doing.
Is there a way to change the settings inside MyClass so that all objects that use it are effected at once?
PhotoJoe47
11-15-2005, 07:11 AM
Let me explain better.
<td class="MyClass">stuff</td>
I want to change the values inside MyClass. Here is why:
I could do something like:
[the td id].className = "NewClass";
or:
[the td id].style.property = "something";
However this requires me going through every td that uses MyClass either by ID or Node. This is too heavy on the client for the ammount of changes im looking at doing.
Is there a way to change the settings inside MyClass so that all objects that use it are effected at once?
Let me see if I can take what you are wanting to do a step further.
I think you want to display somethings in a <td> tags using .MyClass style. But later after something takes place you want to change the style for those <td> tags with a different style.
If this is the case I would not know how to do that. But I think I have seen something about making propreties in the CSS defeniton visible or invisible and then changing the state with javascript. But I don't remember where I saw that, if that is what I saw.
Hopefully someone else will be able to take it from here.
Ultragames
11-15-2005, 07:12 AM
I suppose at least something where i can say set the className to X where the className is Y now.
Maybe indexOf can help me there. But i've not been able to get it running right.
PhotoJoe47
11-15-2005, 07:40 AM
Here is a link to a DOM tutorial that might be of some use to you.
http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=27
glenngv
11-15-2005, 10:43 AM
The CSS Rule object (http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml) of the styleSheet object lets you access and modify the individual rules of a stylesheet.
Ultragames
11-15-2005, 03:36 PM
glenngv: Thank you! Thats exactly what i wanted.
Pyth007
11-15-2005, 08:37 PM
If you are wanting to change className's for an element, where class1 does one thing and class2 does another, check out my response in this thread (http://www.codingforums.com/showthread.php?t=72102).
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.