PDA

View Full Version : resetStyles(element) anything like that?



shachi
11-19-2006, 08:33 PM
Hello everybody,
Can anyone tell me if there is any function like resetStyles in javascript that zaps all javascript made style changes? For e.g if there is a division with a border of 1px dotted and when certain conditions are met javascript changes the border to 1px solid red. Now how do I change the style back to 1px solid(it's not just the case with divs and the default styles can be variable)?

Thanks for your time and interest in my post.

mwinter
11-19-2006, 09:54 PM
Can anyone tell me if there is any function like resetStyles in javascript that zaps all javascript made style changes?

Not automatically, no. You would have to track the changes that you make, yourself.

Assigning an empty string to a property of an in-line style object will remove that declaration:



element.style.color = 'red'; /* #ff0000 */
element.style.color = ''; /* Colour now taken from cascade. */

That would also remove any such declarations applied by the style attribute in markup as they are equivalent.



<span style="color: red;">...</span>

You're probably aware of this, but just in case you weren't...

Mike

shachi
11-20-2006, 11:01 AM
So, there is not any *safe* way to do it?

mwinter
11-21-2006, 02:40 AM
So, there is not any *safe* way to do it?

Nothing comes to mind, no.

Mike

djr33
11-21-2006, 04:29 AM
refresh :p


Is there any way to reset the page without loading, overall? Not just styles, but perhaps everything?

shachi
11-21-2006, 09:37 AM
drj33: that would be really annoying ;p

mwinter: Thanks for your reply. I guess I will have to try something new. Thanks again for your time.


drj33: there probably isn't one right now but I guess there will soon be.