jQuery removeClass() Method
jQuery removeClass() method removes one or more classes from selected elements.
If no class names are specified in the parameter then all classes will be removed from selected elements.
Syntax
Here is a syntax for removeClass() method
$(selector).removeClass( className, function(index, currentclass) );
Parameter | Type | Description |
---|---|---|
className | String | Required. Add one or more space separated classes to be remove. |
function(index,currentclass) | Function | Optional. A function that returns one or more class names to be remove.
|
Example
Here, in this example call removeClass() method
<!DOCTYPE html>
<html>
<head>
<title>jQuery removeClass() method</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("button").click(function(){
$("p").removeClass("param");
});
});
</script>
<style type="text/css">
.param {
font: 16px Verdana, Arial;
font-weight: bold;
color: pink;
}
</style>
</head>
<body>
<p class="param">First paragraph star here</p>
<p class="param">Second paragraph star here</p>
<button>Click here to call removeClass() method</button>
</body>
</html>