They are not the same.

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 without creating a new function in the global
namespace. Beyond that, it behaves as any normal function would. For
example:

$.prompt = function(x) { ... };
jQuery.prompt = function(x) { ... };

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) { ... };

Within the plugin function, "this" refers to the jQuery object it's
being called on. 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;"

Obviously that's a very brief explanation of how plugin functions
work. If you need more detail, seek out some tutorials on writing
jQuery plugins.

Hope that helps.
-Kelly


On May 28, 11:18 am, kiusau <kiu...@mac.com> wrote:
> QUESTION:  Do $.prompt(temp) and $().prompt(temp) mean the same
> thing?  If they do not mean the same, how are they different.
>
> Roddy

Reply via email to