JQuery Attribute-addClass () method, jquery-addclass
1. General Definition and usage
Syntax
$(selector).addClass(class)
Parameters |
Description |
Class |
Required. Specify one or more class names. |
2. Add a class to a function: Use a function to add a class to the selected element.
Syntax
$(selector).addClass(function(index,oldclass)
Parameters |
Description |
Function (index, oldclass) |
Required. Specify to return one or more functions with the class name to be added.
- Index-optional. The index position of the selector.
- Class-optional. The old class name of the selector.
|
Common Definition usage
<Html> <P> Hello kayze-refresh </p>
<P> Hello kayze-refresh </p> <button> Add a class to the first p element </button> </body>
Function addition class usage
1. function (index)
Index-optional. The index position of the selector.
<!DOCTYPE html>
2. function (index, oldclass)
Index-optional. The index position of the selector.
Class-optional. The old class name of the selector.
When the target element of the class needs to be added to the class, the elements containing the class are
When this method is used, the function of the class name is added only when the target element contains the oldClass class name.
<!DOCTYPE html>
I am a cainiao. If you have any other ideas, please leave a message to me and I will learn how to modify it.
Not complete to be continued!