jquery Extend extension methods (class methods and Object methods)

Source: Internet
Author: User
Tags tag name

I. Extension of the jquery class method

/**
* Extended jquery class method (equivalent to class static method $.methodname (param))
*/

$.extend ({con:function (value) {Console.log (value)})//class method call $.con (' The author is a package Jian author is a package Jian author is a package Jian author is a package Jian author is a package Jian author is a package Jian ');

  

Ii. extending the JQuery object approach

/**
* Extend the JQuery object method (equivalent to the static method of the class $ (' #id '). MethodName (param))
* by id/class/tag name gets the object, direct $. Method name is the class (in the hypothetical sense of the class)
* Jquery.fn = Jquery.prototype = {//This is the instantiation of a JQuery object
*init:function (Selector, context) {//....
*//......
* };
*/


});///The second class defines the JQuery method (defining a single method), the two classes are actually the same principle, divided into two types is also my own set, wrong do not spray $.fn.myplugin = function (options) {$options = $.extend ({htm   L: "No Messages", CSS: {"color": "Red", "font-size": "14px"}},options); return $ (this). CSS ($options. css). HTML ($options. html); }//Call $ ('. Ye '). Myplugin ({html: "So easy,yes?", css:{"color": "Green", "font-size": "50px"}); Label on page <span class= '. Ye ' ><span>

  

jquery Extend extension methods (class methods and Object methods)

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.