Use of jquery-attributes (attributes) (ii. Class)

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.