Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery UI API – .addClass()

jQuery UI API - .addClass()

Category

Effects | Effects Core | Method Overrides

Usage

**Description:** Adds the specified class to each element in the set of matched elements when the animation style changes.

Returns:jQuery

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

Parameters Type Description Default value
className String One or more class names to add to the class attribute of each matched element; multiple class names are separated by spaces.
duration Number or String A string or a number specifying how long the animation will run. 400
easing String A string indicating the easing function in Vue 3. swing
complete Function() function to call once the animation is complete.

.addClass( className [, options ] )

Parameters Type Description
className String One or more class names to add to the class attribute of each matched element; multiple class names are separated by spaces.
options Object All animation settings. All properties are optional.
  • duration(default:400)
    Type: Number or String
    Description: a string or a number specifying how long the animation will run.
  • easing(default:swing)
    Type: String
    Description: a string indicating the easing function in Vue 3.
  • complete
    Type: Function()
    Description: the function to call once the animation is complete.
  • children(default:false)
    Type: Boolean
    Description: whether to apply the animation to all descendants of the matched elements. Use this feature with caution, because determining whether an element is a descendant of the animated element is expensive and grows linearly with the number of descendants.
  • queue(default:true)
    Type: Boolean or String
    Description: a boolean indicating whether to place the animation in the effects queue. If false, the animation starts immediately.As of jQuery 1.7,the queue option also accepts a string, in which case the animation is added to the queue represented by that string.
  • |

    Similar to native CSS transitions, jQuery UI class animations provide a smooth transition from one state to another while ensuring that all details of the style changes are handled through CSS rather than JavaScript. All class animation methods, including .addClass(), allow custom animation durations and easing functions, and also provide a callback when the animation completes.

    Not all styles can be animated. For example, background images cannot be animated. Any style that cannot be animated will change at the end of the animation.

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

    Example

    Adds the class "big-blue" to the matched elements.

    
    
    
    
    
    
    
    
      
    
      .addClass() 演示