function Node()
{
}如果使得Node继承自div对象

解决方案 »

  1.   

    function Node(){
       var o=new Div()
       for(var k in o) this[k]=o[i];
     
    }
    或者
     
    function Node(){
     

    }
    Node.prototype=new Div()
      

  2.   

    这代码试了不行
    我现在是用
    function Node()
    {
        this.div = document.createElement('div');
    }var node = new Node();
    document.body.appendChild(node.e);
    这样来处理,有没有办法把Node就定义成为一个Div
      

  3.   

    function Node()
     {
         this.div = document.createElement('div');
     }
     
    var node = new Node();
     document.body.appendChild(node.div);
     
      

  4.   

     
     function Node(html){
      var el=document.createElement('Div');
      for(var k in  this) el[k]=this[k];
      el.innerHTML=html;
      return el;
     }
     Node.prototype.hide=function(){   //添加隐藏方法
      this.style.display="none"
     }
     var node=new Node( 'ok'  ) //实例 并且 HTML = ok
     document.body.appendChild( node   );
     setTimeout( function(){ 
       node.hide();  //隐藏
     },1500 )
      

  5.   

    function mydiv(){
    var div = document.createElement('div'); 
    for(var p in this.constructor.prototype){
            div[p] = this.constructor.prototype[p]
    }
    return div;
    }
      

  6.   

    function mydiv(){
    var div = document.createElement('div'); 
    for(var p in this.constructor.prototype){
            div[p] = this.constructor.prototype[p]
    }
    return div;
    }
    mydiv.prototype.kk = function(){alert('kk')}var md = new mydiv();md.kk();
    //md is HTMLDIVelement
    //md has kk function()