在文档解析完毕后
再进行document.write时,以前的内容会被清空的
你放到函数里和函数外是有区别的,
函数外是解释的过程中就执行的,
在函数里是在文档解析完后,通过按钮触发的,也就是说是在文档解析完后进行write,这样以前的内容都会被清空的。所以最好用createElement("div");
再进行document.write时,以前的内容会被清空的
你放到函数里和函数外是有区别的,
函数外是解释的过程中就执行的,
在函数里是在文档解析完后,通过按钮触发的,也就是说是在文档解析完后进行write,这样以前的内容都会被清空的。所以最好用createElement("div");
{ document.createElement('<div id="tree"><\/div>'); -是酱紫吗?但是下边仍然是null
alert(document.getElementById('tree'));
document.getElementById('tree').innerHTML = this.html;
}display 是一个按钮事件函数<input id="Button1" type="button" value="button" onclick ="display()" />function display()
{
ssssssss();
}
{ document.write('<div id="tree"><\/div>');
this.defer=true;/
alert(document.getElementById('tree')); //为什么这里找不到对象.null?
document.getElementById('tree').innerHTML = this.html;
}
{
var newDiv = document.createElement("div");
document.appendChild(newDiv);// 关键之处
newDiv.innerHTML=this.html;
}