The jQuery extension interface defines two user-defined functions for the jQuery framework, and then calls these two functions. The jquery extension Interface

Source: Internet
Author: User

The jQuery extension interface defines two user-defined functions for the jQuery framework, and then calls these two functions. The jquery extension Interface

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> two custom functions are defined for the jQuery framework using the jQuery extension interface, and then the two functions are called </title>
<Script type = "text/javascript" src = "jquery-1.11.3.min.js"> </script>
<Script>
JQuery. fn. extend ({// call the extension function
Check: function () {// extension of the check function for form elements. Select the single-choice button or check box.
Return this. each (function () {this. checked = true ;});
},
Uncheck: function () {// extension of the check function for form elements. deselect the single-choice button or check box.
Return this. each (function () {this. checked = false ;});
}
});
$ (Function () {// application extension function
$ ("Input [type = checkbox]"). check ();
$ ("Input [type = radio]"). uncheck ();
});
</Script>
</Head>
<Body>
<Input type = "radio"/>
<Input type = "radio" checked = "checked"/>
<Input type = "checkbox"/>
<Input type = "checkbox" checked = "checked"/>
</Body>
</Html>

In the above Code, jQuery. fn. extend is actually jQuery. extend = jQuery. fn. extend = jQuery. prototype. extend. Readers may wonder if jQuery is used. fn. extends are added to extended functions, which should be $ (xxx) during calls ). extend. xxxx (), instead of the $ (xxx) called by the preceding sample code ). xxxx (), of course, must be called after the code is processed.
The Extended Function extend () contains two custom methods in the form of direct object quantity: check () and uncheck (). The check () method defines the selected status for each form element that jQuery matches. The uncheck () method defines the unselected status for each form element that jQuery matches.

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.