<script type="text/javascript">
(function (window,undefined){
function _$(arguments)
{
}
_$.prototype={
constructor:_$,
addEvent:function(){
alert("addEvent");
return this;
},
getStyle:function(){
alert('getStyle');
return this;
}
}
window.$=_$;
_$.onReady=function(fn){
window.$=function(){
return new _$(arguments);
}
fn();
}
})(window)
$.onReady(function(){
$("inq").addEvent().getStyle();
})
</script>
<script type="text/javascript">
(function (window,undefined){
function _$(arguments)
{
}
Function.prototype.method=function(methodName,fn)
{
this.prototype[methodName]=fn;
return this;
}
_$.prototype={
constructor:_$,
addEvent:function(){
alert("addEvent");
return this;
},
getStyle:function(){
alert('getStyle');
return this;
}
}
window.$=_$;
_$.onReady=function(fn){
window.$=function(){
return new _$(arguments);
}
_$.method('addEvent',function(){
alert("addEvent2");
return this;
}).method('getStyle',function(){
alert("getStyle2");
return this;
});
fn();
}
})(window)
$.onReady(function(){
$("inq").addEvent().getStyle();
})
//为什么要加_$.method()? 不加也行?
</script>