JS Package JQ Library for plugins

Source: Internet
Author: User

//In the jquery anonymous function, use Jquery.extend (); method to create a jquery plugin//In the jquery anonymous function, use the object. property = function to create a jquery plugin(function ($) {Jquery.extend ({jia:function (A, b) {returnA +b; }, Jian:function (A, b) {returnA < b? B-a: A-b;    }    }); $.sub={sheng:function (A, b) {returnAb; }, Chu:function (A, b) {returnA < b? B/A: A/b; }} JQuery.fn.Insert=function (a) {alert (a); }}) (JQuery)
<script type="Text/javascript"Src="~/jquery-1.7.1.min.js"></script> <script type="Text/javascript"Src="~/jqtest.js"></script> <script type="Text/javascript">function Btn_click () {varA = prompt ("Please enter a number:"); varb = Prompt ("Please enter a number:"); varA = Prompt ("Please enter a number:"); varc =Jquery.jia (A, b); varD =Jquery.jian (A, b); varE =$.sub.sheng (A, b); varf =$.sub.chu (A, b); Alert ("Add:"+ C +", Subtract:"+ D +", Multiply:"+ E +", Divide:"+f); $.fn. Insert ("La la"); }    </script>

About the "call" syntax: Call([thisobj [,arg1[, arg2[ ,] [,. ArgN]])

Definition: Invokes one method of an object, replacing the current object with another object.

Description: The call method can be used to invoke a method in place of another object. The call method can change the object context of a function from the initial context to a new object specified by Thisobj. If the Thisobj parameter is not provided, then the Global object is used as the thisobj.

About "This"

In the plug-in method, it may be useful to point to the plug-in's this, and to the event-triggered this, so the event-triggered this is obtained with an event: Event.cuerrnttarget

      • Event.currenttarget: Points to the element that the event is bound to, and, as the event bubbles, finds the element
      • Event.target: Always points to the element when an event occurs

Constructor property: Always points to the constructor that creates the current object

Each function has a default property of prototype, and this prototype constructor is the default point to this function

JS Package JQ Library for plugins

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.