First of all, I would like to thank you for responding, and it is my sincere hope that you will follow through as not all are wont.
On May 29, 10:38 am, Kelly <khall...@gmail.com> wrote: > The first situation, $.prompt(x), is just a function, attached to the > jQuery namespace. This is useful if you're creating a function and you > want to put it somewhere . . . If I have understood correctly, the person who writes $.prompt(x) = function( ) { }; rather than prompt(x) = function( ) { }; or function prompt(x) does so because he wants to restrict the use of his function to the jQuery namespace. In other words, he is now free to use the same function name -- namely, prompt(x) -- elsewhere with no fear that it will become confused with the properties, methods, and return values assigned to functional objects created by $.prompt(x). Is this correct? > The second situation, $(selector).prompt(x), is a jQuery plugin. > Typically it would operate on a jQuery object. A jQuery object usually > represents none-or-many matched elements. These plugins are stored in > the jQuery.fn namespace like so: > > $.fn.prompt = function(x) { ... }; > jQuery.fn.prompt = function(x) { ... }; You appear to be saying that jQuery methods and jQuery plug-ins function identically. In other words, any function that can be attached using dot syntax to the form $("someExpression") is either a jQuery method or plug-in that has been previously assigned to the $.fn prototype object. Have I understood correctly? > Within the plugin function, "this" refers to the jQuery object it's > being called on. Is this to say that each time a statement similar to $("someExpression").someJQMethod/Plug-in( ).someOtherJQMethod/Plug- in. . . stillSomeOtherJQMethod/Plug-in; is run a new jQuery object is created whose elements are those matched by the expression contained in the phrase $("someExpression") ? If this is true, is it possible to capture this object by assigning it to some variable? For example, could one write: var someVariableName = $("someExpression"); and then work with someVariableName as if it were just an ordinary JavaScript object with no special relationship to jQuery? >The collection of elements is often iterated over > using this.each(function() { ... }); Within that function, "this" will > refer to an individual matched element. To allow proper chaining, the > final statement in $.fn.prompt() should be "return this;" This is unclear to me, and I am hoping that you can provide an example of what you mean while keeping in mind the issues that I have just raised. Roddy