Maybe a bad title, but this is my problem: I'm building a framework to learn more about javascript. And I want to use ""jQuery"" style.
How can I make a function where the ()
is optional?
$("p").fadeOut(); //() is there
$.each(arr, function(k, v) {...}); //Dropped the (), but HOW?
This is what I have come up with, but it don't work:
$2DC = function(selector)
{
return new function() {
return {
circle : function()
{
//...
}
}
}
}
$2DC("#id1"); //Work
$2DC("#id2").circle(); //Work
$2DC.circle(); //DONT WORK
$.()
is even valid JavaScript.