function Node(){ var o=new Div() for(var k in o) this[k]=o[i];
} 或者
function Node(){
} Node.prototype=new Div()
这代码试了不行 我现在是用 function Node() { this.div = document.createElement('div'); }var node = new Node(); document.body.appendChild(node.e); 这样来处理,有没有办法把Node就定义成为一个Div
function Node() { this.div = document.createElement('div'); }
var node = new Node(); document.body.appendChild(node.div);
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 )
function mydiv(){ var div = document.createElement('div'); for(var p in this.constructor.prototype){ div[p] = this.constructor.prototype[p] } return div; }
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()
var o=new Div()
for(var k in o) this[k]=o[i];
}
或者
function Node(){
}
Node.prototype=new Div()
我现在是用
function Node()
{
this.div = document.createElement('div');
}var node = new Node();
document.body.appendChild(node.e);
这样来处理,有没有办法把Node就定义成为一个Div
{
this.div = document.createElement('div');
}
var node = new Node();
document.body.appendChild(node.div);
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 )
var div = document.createElement('div');
for(var p in this.constructor.prototype){
div[p] = this.constructor.prototype[p]
}
return div;
}
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()