Jquery plugin Learning (III)

Source: Internet
Author: User

For example:
Copy codeThe Code is as follows:
$ (This). test (). hide (). height ();

To implement similar writing behavior, a jquery object should be returned in each plug-in method unless the method needs to explicitly return a value. The returned jquery object is usually the object referenced by this. If you use the each () method to iterate this, you can directly return the iteration result. For the example in the previous section, modify
Copy codeThe Code is as follows:
JQuery. fn. test = function (){
Return this. each (function () {// traverses matched elements. this indicates the object set.
Alert (this. nodeName); // prompt the dom node name of the current jquery object
})
}

Then, we can perform the write operation in the application example. For example, in the following example, a message indicating the node name is displayed, then, use the current node name to overwrite the information contained in the current element, and hide the element slowly.
Copy codeThe Code is as follows:
$ ('Body * '). click (function (){
Certificate (this).test().html (this. nodeName). hide (1000 );
});

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.