JQuery - object and function at the same time?

I am just developing my own mini-infrastructure for the application I was working on, and I was learning jQuery encoding.

I get the $ (selector) .function () method, but how can you call some functions like:

$. Ajax ()

Of course, would it be a dollar symbol that simultaneously refers to both the function and the jquery.fn object?

Thanks in advance!

+5
source share
2 answers

Functions are objects in JavaScript, so they can have properties.

$ jQuery, $() ( , new ); ( , $.browser), $.something

+8

http://jsfiddle.net/vZvgv/1/

var $ = function(str) {
    document.write(str+'<br />');
}

$.ajax = function(str) {
    document.write(str+'<br />');
}

$.answer = 42;

$('dollar');
$.ajax('ajax');
document.write($.answer);
+4

All Articles