[jquery Method Toggleclass (CLASS|FN[,SW])] This method deletes (adds) a class if it exists (does not exist)

Source: Internet
Author: User
Tags button type

A function used to return the name of the style class to toggle on each element in the matching element collection:

If the second argument is callback, then the class name needs to be returned, and the function arguments are interpreted as follows:

1: Receive element's index position and element old style class as parameter

2: A Boolean value to determine whether the style class is added or removed

3. Boolean value to determine if the element contains Class (Sw[switch])


<! DOCTYPE html>Input{font:13px/20px ' Courier New '; color: #000;} . addone{padding:08px;} . addtwo{color:#999;} Button[type= ' button ']{font:400 13px/1.2em ' Courier New ';p adding:3px;} </style><script type= ' Text/javascript ' >    $(function(){        $(' button '). Click (function(){           $(' #user '). Toggleclass (function(index,oldclass) {return' AddTwo ';        });    }); });</script>

[jquery Method Toggleclass (CLASS|FN[,SW])] This method deletes (adds) a class if it exists (does not exist)

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.