jQuery UI API - .removeClass()

Category

Effects | Effects Core | Method Overrides

Usage

Description:While animating style changes, removes the specified class from each element in the set of matched elements.

Returns:jQuery

.removeClass( className [, duration ] [, easing ] [, complete ] )

Parameters Type Description Default
className String One or more class names to be removed from the class attribute of each matched element, separated by spaces.
duration Number or String A string or a number that specifies how long the animation will run. 400
easing String A string indicating theeasingfunction to use. swing
complete Function() A function to call once the animation is complete.

.removeClass( className [, options ] )

Parameters Type Description
className String One or more class names to be removed from the class attribute of each matched element, separated by spaces.
options Object All animation options. All properties are optional.
  • duration(Default:400)
    Type: Number or String
    Description: A string or a number that specifies how long the animation will run.
  • easing(Default:swing)
    Type: String
    Description: A string indicating theeasingfunction to use.
  • complete
    Type: Function()
    Description: A function to call once the animation is complete.
  • children(Default:false)
    Type: Boolean
    Description: Specifies whether the animation should be applied to all descendants of the matched elements. This feature should be used with caution, because determining whether an element is a descendant of the animation is expensive and grows linearly with the number of descendants.
  • queue(Default:true)
    Type: Boolean or String
    Description: A Boolean value indicating whether to place the animation in the effects queue. If false, the animation will begin immediately.As of jQuery 1.7the queue option also accepts a string, in which case the animation is added to the queue represented by the string.

Similar to native CSS transitions, jQuery UI's class animations provide a smooth transition from one state to another, while ensuring that all style change details are handled through CSS without the need for JavaScript. All class animation methods, including.removeClass()allow custom animation durations andeasingeasing functions, and also provide a callback when the animation is complete.

Not all styles can be animated. For example, animating a background image. Any style that cannot be animated will be changed at the end of the animation.

This plugin extends jQuery's built-in.removeClass()method. If jQuery UI is not loaded, calling the.removeClass()method will not directly fail, because the method exists in jQuery. However, the expected behavior will not occur.

Examples

Remove the class "big-blue" from the matched elements.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>.removeClass() 演示</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <style>
  div {
    width: 100px;
    height: 100px;
    background-color: #ccc;
  }
  .big-blue {
    width: 200px;
    height: 200px;
    background-color: #00f;
  }
  </style>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
 
<div class="big-blue"></div>
 
<script>
$( "div" ).click(function() {
  $( this ).removeClass( "big-blue", 1000, "easeInBack" );
});
</script>
 
</body>
</html>

Other Extensions