This question already has an answer here:
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.
This question already has an answer here:
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.
Edit
Okay, complete re-write. It's been a while, I've learned a bit and the comments have helped.
Old Post
I was just working with something like this. Here's a solution I came up with...
Now you can call
myElement.removeClass('myClass')
or chain it:
myElement.removeClass("oldClass").addClass("newClass");
where
MyID
is the ID of the element and MyClass is the name of the class you wish to remove.UPDATE: To support class names containing dash character, such as "My-Class", use
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
try:
It's very simple, I think.