jquery Plugin jquery Plugin development

Source: Internet
Author: User

Class-level plug-in development, which is primarily defined as a global method in jquery://The first way of writing jquery.myfunc = function (str) {    alert ("define method directly in jquery", str)}//call mode  $. MyFunc ("hello!"); /second notation Jquery.extend ({    myfunc:function (str) {        alert ("Extend extension $ method", str)    }})//Call Way  $.myfunc (" Hello! "); /third: In order to not pollute the global, mount an object as a namespace, all the custom methods are put here to ensure that jquery is globally secure. jquery.define={    myfunc:function (str) {        alert ("notation for Namespaces", str)    }}//called: $.define.myfunc ("Hello");// The above three kinds is the level plug-in development way, is not commonly used, from the invocation way to see, they are the global execution, does not need to bind the node object. Object level plug-in development: there is a canonical template; (function ($) {    $.fn.plugin = function (options) {        var defaults = {            //various default parameters        }        var options = $.extend (defaults,options);//The passed parameter overrides the default parameter        This.each (function () {            var _this = $ (this);  Cache the node objects that the plugin passes in.            //execute Content                                })        return $ (this);   Returns the Node object in order to support chained calls.    }}) (jQuery);//Call Way $ ("selector"). Plugin ({    //custom parameters, JSON format})

  

Https://www.cnblogs.com/chengyunshen/p/7277305.html

jquery Plugin jquery Plugin development

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.