So I was wondering if anyone could help me understand how the jQuery ‘class’ works. From what I can tell, it works like a static class like such:
if(!$) { var $ = new function(){} }
I think..
Now, what is confusing to me, is how you can call a method both with OR without arguments like such:
$("a").removeClass("test");
$.get('myhtmlpage.html', myCallBack);
I am assuming passing that argument simply returns document.getElementById(argument);
But how? How is this argument passed into the class after the fact like this? also, is this some result of method chaining?
Anything info to help me understand what is going on would be great! Thanks.
I’m working with the jQuery source here, so you can look at it as well.
The
$function isn’t explicitly defined, but instead linked to thejQueryobject:The
jQueryobject is defined like so:The
init: function( selectorpart handles$('foo')cases.If no parameters are given, the another function is used: