闲来无事,写个简单的js类,高手别看了~B("id名").Method 挺简单的,下面的方法名,已经给出方法的作用了,就不做解释了,直接拿去用吧!
Code
function P(E)
{
var N = "";
this.Z = document.getElementById(E);
this.val = function(){
if(arguments.length==0)
{
return this.Z.value;
}
else if(arguments.length=1)
{
this.Z.value = arguments[0];
}
}
this.appendValAfter = function(){
this.Z.value = this.val() + arguments[0];
}
this.appendValBefore = function(){
this.Z.value = arguments[0] + this.val();
}
this.html = function(){
if(arguments.length==0)
{
return this.Z.innerHTML;
}
else if(arguments.length = 1)
{
this.Z.innerHTML = arguments[0];
}
}
this.appendHtmlAfter = function(){
this.Z.innerHTML = this.html() + arguments[0];
}
this.appendHtmlBefore = function(){
this.Z.innerHTML = arguments[0] + this.html();
}
this.hide = function(){ this.Z.style.display = "none";}
this.show = function(){ this.Z.style.display = "inline-block";}
this.clearV = function(){ this.Z.value = N;}
this.clearH = function(){this.Z.innerHTML = N;}
this.toggle = function(){
var S = this.Z.style; S.display=="inline-block"?S.display="none":S.display="inline-block";
}
//this.css = function(){ return this.Z.css}
}
//o.prototype.GV =
function B(E){
return (new P(E));
}
function P(E)
{
var N = "";
this.Z = document.getElementById(E);
this.val = function(){
if(arguments.length==0)
{
return this.Z.value;
}
else if(arguments.length=1)
{
this.Z.value = arguments[0];
}
}
this.appendValAfter = function(){
this.Z.value = this.val() + arguments[0];
}
this.appendValBefore = function(){
this.Z.value = arguments[0] + this.val();
}
this.html = function(){
if(arguments.length==0)
{
return this.Z.innerHTML;
}
else if(arguments.length = 1)
{
this.Z.innerHTML = arguments[0];
}
}
this.appendHtmlAfter = function(){
this.Z.innerHTML = this.html() + arguments[0];
}
this.appendHtmlBefore = function(){
this.Z.innerHTML = arguments[0] + this.html();
}
this.hide = function(){ this.Z.style.display = "none";}
this.show = function(){ this.Z.style.display = "inline-block";}
this.clearV = function(){ this.Z.value = N;}
this.clearH = function(){this.Z.innerHTML = N;}
this.toggle = function(){
var S = this.Z.style; S.display=="inline-block"?S.display="none":S.display="inline-block";
}
//this.css = function(){ return this.Z.css}
}
//o.prototype.GV =
function B(E){
return (new P(E));
}