How to Use Remove Class Method in jQuery?

The removeClass method is used to remove one or more classes from the selected element. This method is one of the popular jQuery CSS selector methods. The remove class method can be used in jQuery to remove any specified classes from any element. 

jquery remove class

By AnkurAnkur on Mar 03, 2020
Basic Syntax:
$(element).removeClass( "myClass yourClass" )
-------------------------------------------------------------------------------------
  
Html code example:
<p class="red highlight">test1</p>
<p class="red highlight marked">test2</p>
<p class="red highlight">test3</p>
<p class="red highlight">test4</p>

// remove all highlight class from p tag
<script>
	$( "p" ).removeClass( "highlight" )
</script>

// output after execution of this code
<p class="red">test1</p>
<p class="red marked">test2</p>
<p class="red">test3</p>
<p class="red">test4</p>

Source: api.jquery.com

Add Comment

8

jquery remove class

By Code_BreakerCode_Breaker on Jan 10, 2021
//Remove this same line after copying
Basic Syntax:
$(element).removeClass( "myClass yourClass" )
-------------------------------------------------------------------------------------
  
Html code example:
<p class="red highlight">test1</p>
<p class="red highlight marked">test2</p>
<p class="red highlight">test3</p>
<p class="red highlight">test4</p>

// remove all highlight class from p tag
<script>
	$( "p" ).removeClass( "highlight" )
</script>

// output after execution of this code
<p class="red">test1</p>
<p class="red marked">test2</p>
<p class="red">test3</p>
<p class="red">test4</p>

Add Comment

13

jquery remove and add class

By MatteowebMatteoweb on Jul 01, 2020
$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );

//OR
if ($( "#foo" ).hasClass('className')) {
	$( "#foo" ).removeClass( 'className');
} else {
  $( "#foo" ).addClass( 'className');
}

Add Comment

3

jquery remove multiple classes

By Motionless MandrillMotionless Mandrill on Dec 04, 2020
$("element").removeClass("class1 class2");
//One or more CSS classes to remove from the elements,
//these are separated by spaces.

Source: stackoverflow.com

Add Comment

4

jquery remove class

By Obedient OstrichObedient Ostrich on Feb 13, 2021
$("button").click(function(){
  $("p").removeClass("intro");
 });
//Html code example:
<p class="red highlight">test1</p>
<p class="red highlight marked">test2</p>
<p class="red highlight">test3</p>
<p class="red highlight">test4</p>

// remove all highlight class from p tag
<script>
	$( "p" ).removeClass( "highlight" )
</script>
// example $(element).removeClass( "myClass yourClass" )

Add Comment

1

jquery remove class

By NitriaNitria on Nov 19, 2020
$("#div1").on("click", function () {
    if ($(this).hasClass("active")) {
      setTimeout(function () {
        $("#div1").removeClass("active");
      }, 10);
    }
  });

Add Comment

-1

It removes the class from all elements which do not have the specified class.

Javascript answers related to "jquery remove class"

View All Javascript queries

Javascript queries related to "jquery remove class"

jquery remove class jquery select element with class if a class exists jquery angular how to use service in class create react component class export default class react how to change style class by using onclick function with multiple buttons in react js how to write statefull class in react push values to state array class react flutter json to class how to get all elements with same class in javascript angualr add class to component js get class property javascript class example delete class through the dom A class member cannot have the 'const' keyword. React Class Component toggle class ng class in angular Add class query selector vanilla js add class Datetimepicker jquery for loop in jquery array Jquery addeventlistener display non using Jquery jquery each array object jquery get id value jquery modal on show + target button jquery modal show backdrop static jquery replace multiple words jquery replace text jquery replace text in div jquery replicate div on drag jquery reset form jquery run after page load jquery run code after 5 seconds jquery safely use $ jquery save method jquery save upload image jquery script jquery script cdn stackoverflow jquery script tag source google jquery script url jquery scroll down 1 pixel jquery scroll to bottom jquery scroll to element jquery scroll to id jquery scroll to position jquery scroll to top of div jquery scroll to top of div animate jquery scroll when object appear on screen make animation jquery scrollHeight jquery scrolltop animate jQuery search immediate children Jquery search in json Jquery search in json - Get json data jquery see if checkbox is checked jquery see if element is visible jquery select jquery select 2 classes jquery select a dynamic element jquery select attribute jquery select box change event jquery select by data attribute jquery select by name jquery select by name attribute jquery select clear options jquery select direct child jquery select div in div jquery select dropdown jquery select element based on for attribute jquery select element inside element jquery select element with data jquery select element with two classes jQuery select elements by name jQuery select immediate children jquery select input value empty and hasclass jquery set select readonly jquery set select value jquery this value jquery to animate a flash to the button selected radio button onclick jquery set input value jquery set onclick jquery change inner html in jquery jquery modal popup jquery click method sortable jquery How to check checked checkbox in jquery jQuery Effects - Animation get elements by id like jquery jquery-3.4.1.min.js Jquery select change event jquery string split Get current date in jquery in dd/mm/yyyy format this id jquery jquery form validation Javascript | jquery sleep jquery foreach array jquery toastr Jquery if radio button checked jquery 3.5 1 min js jquery find object in array Jquery submit form jquery wait jquery get data attribute jquery min js cdn link Onchange in jQuery jquery $.ajax post json get value by id in jquery jquery get url parameter jquery cdn google convert int to string jquery angular formarray remove all how to remove " in json in "flutter" remove duplicates in json in flutter remove attribute javascript javascript remove first character from string how to remove duplicate array object in javascript remove element from array javascript how to remove element from array in foreach javascript how to remove the last element of an array in javascript remove elemtns from an array with splice js eventlistener to add and remove stylings remove mime type from base64 javascript javascript remove the last element from array remove a function added to eventhandler remove duplicates in array how to remove all element from formarray Mongodb Remove array element by index how do i remove all vowels from a string in javascript and return the result remove element from array remove duplicate objects based on id from array angular 8 remove one element using splice remove undefined from array how to remove elements from object in typescript remove escapes from json

Browse Other Code Languages

CodeProZone