How to Remove Class Using Javascript?

In this article, we remove the CSS class using javascript. We create a simple text with some CSS and create a button. After clicking on the button call a javascript function and remove the class using javascript.


<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">

<div id="myDIV" class="mystyle"> Text with CSS</div> <br>

<button onclick="myFunction()">Remove Class</button>



.mystyle {
  width: 50%;
  padding: 25px;
  background-color: red;
  color: white;
  font-size: 25px;
  box-sizing: border-box;


function myFunction() {
  var element = document.getElementById("myDIV");

I hope this code will helpful for you.