昨天闲来无聊写来玩玩。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var cd=document.all.d0;
var tag=1;
function setCd(obj,evt)
{
var e=(evt)?evt:window.event;
if (window.event) {
e.cancelBubble=true;
} else {
//e.preventDefault();
e.stopPropagation();
}
cd=obj;
}
function addDiv()
{
if(cd==null)
{
cd=document.all.d0;
}
var cs=eval("o"+cd.id.substr(1));
var ct=1+cs.value*1;
var strtext="";
for(i=0;i<ct;i++)
{
strtext+=" ";
}
strtext+=document.all.textfield.value;
cd.innerHTML+="<div id='d"+tag+"'οndblclick='setCd(this,event)'><input type='hidden' id='o"+tag+"' value='"+ct+"'/>"+strtext+"</div>";
tag++;
}
</script>
</head>
<body>
<table width="668" height="151" border="1">
<tr>
<td width="326"><div id="d0" οndblclick="setCd(this,event)" style="z-index:-1">
总节点
<input type="hidden" id="o0" value="0" />
</div></td>
<td width="326"><label>
<input type="text" name="textfield" />
<input type="button" name="Submit" value="按钮" οnclick="addDiv()" />
</label></td>
</tr>
</table>
</body>
</html>