Home >>jQuery Tutorial >jQuery removeClass() Method
jQuery removeClass() method in jQuery is an inbuilt method and is used to removes one or multiple class names from the given selected elements.
Syntax:$(selector).removeClass(classname,function(index,currentclass))
Parameter | Description |
---|---|
classname | It is optional parameter and is used to Specifies one or more class names to remove |
function(index,currentclass) | It is optional parameter that returns one or more class names to remove
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$("p").removeClass("txt1");
});
});
</script>
<style>
.txt1 {
font-size: 120%;
color: green;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p class="txt1">This is a paragraph.</p>
<p class="txt1">This is another paragraph.</p>
<button class="btn1">Click me to remove class</button>
</body>
</html>
This is a paragraph.
This is another paragraph.