How To Remove CSS Class Using jQuery

jqueryTo remove CSS class using jQuery, you only need to use removeClass method.  In the sample code given below, we are removing CSS class myStyle from DIV element using function divClass().

<!DOCTYPE html>
<html>
<head>
<title>jQuery Tutorial </title>

<script src="http://code.jquery.com/jquery-latest.js"></script>


<!-- CSS Class --> 
<style type="text/css">
 
.myStyle
{
    background-color:red;
    color:white;
    font-weight: bold;    
}
 </style>
 
 <!-- jQuery Code to remove CSS Class -->
<script type="text/javascript">
 
 function divClass(){
    
    $('#divHello').removeClass('myStyle');
 }

</script>
 
</head>
<body>
<input type="button" value="Remove Class" onclick="divClass()"/>
<br />
<br />
<div id="divHello" class="myStyle">
Hello World!
</div>
 
</body>
</html>

 

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •