//修改属性
/*
两个参数:修改属性
一个参数:获取属性
一个参数:批量设置属性
*/
Base.prototype.attr=function(property,value){
if(value!=undefined){
for(var i=0;i<this.ele.length;i++){
this.ele[i][property]=value;
}
}else if(typeof property==‘object’){
//批量设置
for(var j=0;j<this.ele.length;j++){
for(var m in property){
this.ele[j][m]=property[m];
}
}
}else{
//获取属性值
return this.ele[0][property];
}
return this;
};
//修改内容
/*
1.有参数:修改内容
2.无参:获取指定节点的内容
*/
Base.prototype.text=function(value){
//arguments
//有参数
if(value!=undefined){
//遍历节点
for(var i=0;i<this.ele.length;i++){
this.ele[i].innerHTML=value;
}
return this;
}
return this.ele[0].innerHTML;//返回第一个节点的内容
};
//事件
Base.prototype.click=function(fn){
for(var i=0;i<this.ele.length;i++){
this.ele[i].οnclick=fn;
}
};
//hover事件
Base.prototype.hover=function(fn_over,fn_out){
for(var i=0;i<this.ele.length;i++){
this.ele[i].οnmοuseοver=fn_over;
this.ele[i].οnmοuseοut=fn_out;
}
return this;
};
//效果类型
//显示
Base.prototype.show=function(){
for(var i=0;i<this.ele.length;i++){
this.ele[i].style.display=‘block’;
}
return this;
};
//隐藏
Base.prototype.hide=function(){
for(var i=0;i<this.ele.length;i++){
this.ele[i].style.display=‘none’;
}
return this;
};
//切换
Base.prototype.toggle=function(){
for(var i=0;i<this.ele.length;i++){
var o=this.ele[i];
//获取节点状态
var sty=o.style.display;
if(sty==‘’){
sty=window.getComputedStyle(o,null).display;
}
if(sty==‘none’){
o.style.display=‘block’;
}else{
o.style.display=‘none’;
}
}
return this;
};
//在创建一个html