This series of articles includes five articles: attribute, class, Html code, text, and value.
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.
. 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 ");
After running, you need to refresh it to load jqueryXmlns = "http://www.w3.org/1999/xhtml">
JQuery-Attributes (attribute) usage (
Ii. Category)
This series of articles mainly describes how to use Attributes of the jQuery framework (Attributes). I will describe it in the instance mode, which is simple and comprehensive and does not involve
Deep Learning, my learning method: Getting started first, then advanced!
This series of articles includes five articles: attribute, class, Html code, text, and value.
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 ");
// Click the button to view the effect
Div id = "div_a1"
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"); // click the button to view the effect
Div id = "div_b1"
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"); // click "3" to check the effect.
Div id = "div_c1"