一個簡單的javascript類

來源:互聯網
上載者:User

                     閑來無事,寫個簡單的js類,高手別看了~B("id名").Method  挺簡單的,下面的方法名,已經給出方法的作用了,就不做解釋了,直接拿去用吧!

 

{
this.style.display='none'; document.getElementById('Code_Closed_Text_050811').style.display='none'; document.getElementById('Code_Open_Image_050811').style.display='inline'; document.getElementById('Code_Open_Text_050811').style.display='inline';
}" id="Code_Closed_Image_050811" style="display: none">{
this.style.display='none'; document.getElementById('Code_Open_Text_050811').style.display='none'; getElementById('Code_Closed_Image_050811').style.display='inline'; getElementById('Code_Closed_Text_050811').style.display='inline';
}" id="Code_Open_Image_050811">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));
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.