Use of jquery-attributes (attributes) (ii. Class)
This seriesArticleThis article mainly describes how to use attributes of the jquery framework (attributes). I will describe it in the form of examples. It is based on simplicity and comprehensiveness and will not be very deep. My learning method is as follows: getting started, advanced!
This series of articles are divided into: attribute, class, htmlCodeFive articles, text articles, and value articles.
This article describes the usage of addclass (class), removeclass (class), and toggleclass (class.
If you have any suggestions or comments on this series of articles, please send to: sjzlgt@qq.com
You can go to the official jquery website to learn more about jquery.
Copyright: code-cat blog: http://www.cnblogs.com/bynet/ reprint please keep the original author, source and copyright information!
1. addclass (class) Usage
Definition: add the specified class name for each matching element.
Returned value: Object
Parameter: Class (string): one or more CSS class names to be added to the element. Separate multiple CSS class names with spaces.
Example: add the 'redborder' class to all images in the DIV with ID "div_a1.
Code: $ ("# div_a1 IMG"). addclass ("redborder ");
2. removeclass (class) Usage
Definition: deletes all or specified classes from all matching elements.
Returned value: Object
Parameter: Class (string): (optional) one or more CSS class names to be deleted. Separate multiple CSS class names with spaces.
Example: Delete the 'redborder' class from all images in the DIV with ID "div_b1.
Code: $ ("# div_b1 IMG"). removeclass ("redborder ");
3. toggleclass (class) Usage
Definition: if there is (does not exist), delete (ADD) a class.
Returned value: Object
Parameter: Class (string): CSS Class Name
Instance: Switch the 'redborder' class to all images in the DIV with ID "div_c1. Code: $ ("# div_c1 IMG"). toggleclass ("redborder ");
Download the HTML source file of this article: Download