HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Learn how to remove a class name from an element with JavaScript
Step 1) Add HTML:
In this example, we will use a button to remove the "mystyle" class from the <div> element with id="myDIV":
<button onclick="myFunction()">Try it</button>
<div id="myDIV"
class="mystyle">
This is a DIV element.
</div>
Step 2) Add CSS:
Style the specified class name:
.mystyle {
width: 100%;
padding:
25px;
background-color: coral;
color: white;
font-size: 25px;
}
Step 3) Add JavaScript:
Get the <div> element with id="myDIV" and remove the "mystyle" class from it:
function myFunction() {
var element = document.getElementById("myDIV");
element.classList.remove("mystyle");
}
Try it Yourself »