设置一个接受插件的方法
Base.prototype.extend=function(name,fn){
Base.prototype[name]=fn;
};
$().extend(‘drag’,function(tags){
};
封装css选择器
//通过构造函数来传递节点
if(typeof args==’string’){
case ‘#’:
this.elements.push(this.getId(args.substring(1));
break;
case ‘.’:
this.elements=this.getClass(args.substring(1));
break;
default:
this.elements=this.getTagName(args);
}
}
//获取id节点
Base.prototype.getId=function(id){
return document.getElementById(id);
}
//获取元素节点数组
Base.prototype.getTagName=function(tag,parentNode){
var node=null;
var temps=[];
if(parentNode!=unedfined){
node=parentNode;
}else{
node=document;
}
var tags=node.getElementByTagName(tag);
for(var i=0;i