Transfer: jquery plugin development methods

2010-11-27  来源:本站原创  分类:Web  人气:105 

jQuery plugin for the development of Tigong two methods, namely:

jQuery.fn.extend (object);

jQuery.extend (object);

jQuery.extend (object); for extending jQuery the class itself. for the class to add new methods.

jQuery.fn.extend (object); to the jQuery object to add methods.

What is it fn. View jQuery code is not difficult to find.

jQuery.fn = jQuery.prototype = {

init: function (selector, context) {//....

//......

};

Original jQuery.fn = jQuery.prototype. On the prototype certainly no stranger to friends.

Although javascript is no clear concept of the class, but with the class to understand it would be more convenient.

jQuery is a very good package category, such as we use the statement $ ("# btn1") will generate a jQuery instance of the class.

jQuery.extend (object); to add jQuery to add class methods class, can be interpreted as adding a static method. Such as:

$. Extend ({

add: function (a, b) {return a + b;}

});

It is to add jQuery to add a "static method", after the introduction of jQuery can place, use this method, the

$. Add (3,4); / / return 7

jQuery.fn.extend (object); on jQuery.prototype get in expansion, is to add jQuery class "member function." jQuery instance of the class can use the "member function."

For example, we want to develop a plug-in, do a special edit box, when it is clicked, it will alert the current contents of the edit box. Can do:

Java code

  1. $. Fn.extend ({
  2. alertWhileClick: function () {
  3. $ (This). Click (function () {
  4. alert ($ (this). val ());
  5. });
  6. }
  7. });
  8. $ ("# Input1"). AlertWhileClick (); / / page is: <input type="text"/>

$.fn.extend({  

    alertWhileClick:function(){  

        $(this).click(function(){  

             alert($(this).val());
         });  

     }  

 });  

 $("#input1").alertWhileClick(); // Page for  :<input type="text"/>

$ ("# Input1") is a jQuery instance, when it calls the member method alertWhileClick after they realized the expansion, each time it is clicked will first pop up when editing the contents of the current.

Actual development process, of course, will not do such a white plug, in fact, a wealth of operations jQuery Tigong documents, events, CSS, Ajax, results-based approach, combined with these methods, we can develop a more Niubility plug-ins.

Original: http://ioryioryzhan.javaeye.com/blog/232971

相关文章
  • Transfer: jquery plugin development methods 2010-11-27

    jQuery plugin for the development of Tigong two methods, namely: jQuery.fn.extend (object); jQuery.extend (object); jQuery.extend (object); for extending jQuery the class itself. for the class to add new methods. jQuery.fn.extend (object); to the jQu

  • jQuery plugin development full resolution (transfer) 2010-03-10

    jQuery plug-in development include two kinds: One is the class-level plug-in development, that is, to jQuery to add a new global function, which is equivalent to a jQuery method to add class itself. jQuery jQuery global namespace function is a functi

  • jQuery plugin development (transfer) 2010-12-22

    jQuery plugin development, including both: One is the class-level plug-in development, that is, to jQuery to add a new global function, which is equivalent to the method of jQuery to add the class itself. jQuery jQuery is a global namespace function

  • jQuery plug-in development full-resolution (change) 2009-05-08

    jQuery plug-in development includes two kinds: One is the class-level plug-in development, that is, to jQuery to add a new global function, which is equivalent to the class itself, add the jQuery way. jQuery is a part of the global function namespace

  • jQuery plug-in development - is actually very simple 2010-07-09

    [Introduction] jQuery has been widely used, with its simple API, the manipulation of the DOM of a powerful, easy to expand more and more web Development staff of the favorite, I also released in the community Henduo the jQuery plug-in and many people

  • JQuery Plugin Development Getting Started (b) 2010-12-02

    ] [Practice jQuery development or use, more inspiration came from practice, not copy | | paste (the students can pursue ism left). So here I will use a simple example to illustrate the jQuery plug-in development process, can learn by analogy to see T

  • jQuery plug-in development 2010-03-29

    jQuery plug-in development.

  • JQuery Plugin Development Getting Started (a) 2010-12-02

    jQuery plug-in development - is very simple [Introduction] jQuery has been widely used, with its simple API, for DOM manipulation of the powerful, easy to extend more and more web developers love, I am in the community also released a lot of jQuery p

  • JQuery Plugin Development Quick Start (c) 2010-12-02

    Extended] [ Sometimes the user is not so easily satisfied, so some people shouted: "I want to set up their own value, why not provide this function?." So now we need to open a way for the user, to set jSlider the value, the first consideration i

  • AND Learning JQuery plug-in development source! 2010-11-03

    jQuery subject as follows: (Function (){...})(); This expression declares an anonymous function (first bracket), and then execute it (second bracket) jQuery plugin for the development of Tigong two methods, namely: jQuery.extend (object); for extendi

  • JQuery plug-in development class level 2010-11-17

    Here are several methods of jQuery to create a global function: / * Class-level plug-in development * / / / The first method: add a new global function jQuery.foo = function () { alert ("this is a test, the first method a whole function"); }; jQ

  • Transfer: JQuery plug-in installed 2011-05-28

    Transfer from: http://www.cnblogs.com/shulin/archive/2010/08/09/1796146.html There are three commonly used plug-in support jQuery smart tips: 1.jQueryWTP 2.Spket 3.Aptana Before installing the plug-ins need to install the eclipse, if you have install

  • jquery plug-in development approach 2008-08-31

    jQuery for the development of plug-in Tigong two methods, namely: jQuery.extend (object); for the class to add jQuery to add class methods can be interpreted as adding a static method. Such as: $. extend (( add: function (a, b) (return a + b;) )); Th

  • jquery plug-in development template 2010-12-10

    Original text from the Internet. (Function ($) { / / / / Plugin definition / / $. Fn.hilight = function (options) { debug (this); / / Build main options before element iteration var opts = $. extend ({}, $. fn.hilight.defaults, options); / / Iterate

  • (Transfer) of maven plug-in development 2010-12-07

    Maven plugin development - so that maven uses a more flexible For accustomed to using maven to build, manage people, projects, maven is the project development, testing, deployment of a weapon: the centralized management of the library; rely on trans

  • Common plug-in === transfer jquery 2010-12-03

    jQuery plug-ins can enhance the usability of Web sites, effectively improve the user experience, you can also create a new site, greatly reducing development time. Now a lot of jQuery plug-in, do your project requirements according to choice, but the

  • Eclipse Plug-in Development Quick Start (transfer) 2010-03-26

    I just repaired my car, I need to unscrew a screw. So I opened my wrench kit, trying to find the right wrench. But neither of those models wrench, because the screws are all metric standards. I can only use the most similar to the ideal size wrench.

  • Eclipse plug-in development - in-depth understanding of search (Search) function and extension points 2010-03-29

    Transfer from http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-search/index.html Find function is Eclipse a very important feature, which provides a rich search results, the results of user-friendly display, as well as convenient location, a

  • JQuery Plugin - Uploadify (easy to use, upload the plugin) 2010-09-15

    Uploadify is a JQuery plug-in, it will help you easily simply upload one or more files to your website. It requires Flash control and background development language support, extensive configuration parameters, but also easy to use, easy to get start

  • Hudson plugins plug-in development based on 2010-09-19

    by Justin 1. On the Hudson plug-in development environment set up Hudson officials said is the development of plug-ins rely on Maven2 and JDK6.0 or later. Would not be here on the Maven-related details. ok, first of convenience, we need to configure