On May 5, 1:53 pm, Matt Kruse <m...@thekrusefamily.com> wrote:
> > (function($) {$.fn.METHOD_NAME = function() {FUNCTION_CODE}})(jQuery);
>
> This passes the jQuery object to the internal anonymous function, then
> operates on $. It adds a property to the $.fn object, which in jQuery is the
> prototype for the jQuery object.
>
> So $.fn.METHOD will be available as $().METHOD() because $() creates a
> jQuery object, and METHOD is in its prototype object.
>
> Hope that helps.

It helps enormously, as well as everything that came before it.  What
alert($) returns, however, is the following:

function (selector, context) {
    return new (jQuery.fn.init)(selector, context);
}

What I can understand from this is that each time jQuery is run it
passes a pair of parameters called selector and context to what
appears to the jQuery.fn.init object.

Now, I understand well how to pass parameters to a function.  I also
understand that methods and properties are pretty much treated the
same by the object in which they are contained.  What I do not
understand is why jQuery.fn.init is not written as jQuery.fn.init()
where init() is a method of the jQuery.fn prototype object.

Roddy





Please see 
http://homepage.mac.com/moogoonghwa/practice/jQuery/jQ_NewMethods.html

Can you explain the above

Reply via email to