jQuery插件开发
1:(function($){
})(jQuery)
2:定义方法
a:
$.test2=function () {
alert("test2");
}
页面中引用 $.test2();
b:
$.fn.mytest=function(){
alert("mytest");
}
页面中引用 $("#abc").mytest();
c: 覆盖
$.extend({
add:function(a,b);
});
页面中引用 $.add(3,4);
完整的例子
(function($){
$.test=function () {
alert("test");
}
var private3=function () {
alert("private3");
}
$.fn.mytest=function(){
var privatetest=function () {
alert("private");
}
privatetest();
$.test();
private3();
}
$.extend({
add:function(a,b){return a+b;}
});
})(jQuery)