📅  最后修改于: 2020-11-26 01:18:12             🧑  作者: Mango
addclass()方法用于将一个或多个类名称添加到所选元素。此方法仅用于将一个或多个类名称添加到类属性,而不会删除现有的类属性。
如果要添加多个类,请用空格分隔类名称。
句法:
$(selector).addClass(classname,function(index,oldclass))
Parameter | Description |
---|---|
Classname | It is a mandatory parameter. It specifies one or more class names which you want to add. |
Function (index, currentclass) | It is an optional parameter. It specifies a function that returns one or more class names to be added.
|
让我们以一个示例来演示jQuery addclass()方法的效果:
This is a heading
This is a paragraph.
This is another paragraph.