Could anyone let me know how to remove a class on an element using JavaScript only? Please do not give me an answer with jQuery as I can't use it, and I don't know anything about it.
You could simply set the elements class to nothing.
or if you wanted to keep a particular class you could just reset the class
|
|||||||||||||||||||
|
where |
|||||||||||
|
|
|||
|
Here's a way to bake this functionality right into all DOM elements:
|
|||||||
|
try:
|
|||
|
Actually, the right way (standard) to do (but only works with Firefox3.6): ELEMENT.classList.remove("CLASS_NAME"); I'm going to publish an article about that on http://hacks.mozilla.org next week with fallback mechanism for other browsers. Documentation: https://developer.mozilla.org/en/DOM/element.classList |
|||||||
|
Check this out: http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript This answer has some good examples. Patrick. |
|||
|