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 |
|||||||||||||||||
|
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 |
|||||||||||||||||
|
|
|||
|
Here's a way to bake this functionality right into all DOM elements:
|
|||||||||
|
try:
|
|||
|
Check this out: http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript This answer has some good examples. Patrick. |
|||
|
More at https://developer.mozilla.org/en-US/docs/Web/API/element.classList |
|||
|
All of these answers are way too complicated, try
The result would be a return of the string
Super easy. Credits go to jondavidjohn Remove portion of string in Javascript |
|||
|
There is also Take a look at this jsFiddle example to see it in action. |
|||||
|