You can cling to whatever you want. If you define yourself $.fn, it is important that you are return thisat the end of your function.
javascript , ! , . , - , . .
var obj = {
test : function(){
alert("Y");
return this;
},
test2 : function(){
alert("2");
return this;
}
}
obj.test().test2();
API- jQuery
$.fn.test = function(){
var methods = {
method0 : function(){
alert("method0");
return this;
}
};
return methods;
}
var api = $("obj").test();
api.method0();
$("obj").test().method0();
jQuery. $("obj").test().addClass("test"), API!