纯js学写插件
//无限链式编程
function $(id){
return new fn(id);
}
var fn = function(id) {
return this.getElementById(id);
};
fn.prototype.getElementById=function(id){
this.element = document.getElementById(id);
return this;
}
fn.prototype.Method=function(){
this.element.style.color="red";
return this;
}
fn.prototype.FontSizes=function(){
this.element.style.fontSize="30px";
return this;
}
window.onload=function(){
$("newtxt").Method().FontSizes();
}

浙公网安备 33010602011771号