//立即执行函数
(function(){
//构造函数
function _$(selector){
this.ele=document.getElementById(selector);
}
//原型扩展方法/属性
_$.prototype={
//获取某个dom的html
html : function(){
return this.ele.innerHTML;
},
add : function (){
return this
}
//扩展更多方法
}
//命名空间绑定
var bj=window.$=window.bj=function(selector){
return new _$(selector);
}
bj.func=function(){
}
})()
转载于:https://my.oschina.net/wengjunbin/blog/195011