嗯
应该算是最新手的问题了
<!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>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
window.onload=function()
{
var div=document.getElementById("divTest"); //取得ID为divTest的div
var textBox=document.createElement("input"); //创建一个input标签
textBox.type="text"; //类型为text,即文本框
textBox.value="这是createElement创建出来的文本框"; //设置其内容
div.appendChild(textBox); //添加到div中
}
</script>
</head>
<body>
<div id="divTest">
这是一个DIV
</div>
</body>
</html>
应该算是最新手的问题了
<!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>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
window.onload=function()
{
var div=document.getElementById("divTest"); //取得ID为divTest的div
var textBox=document.createElement("input"); //创建一个input标签
textBox.type="text"; //类型为text,即文本框
textBox.value="这是createElement创建出来的文本框"; //设置其内容
div.appendChild(textBox); //添加到div中
}
</script>
</head>
<body>
<div id="divTest">
这是一个DIV
</div>
</body>
</html>
<input type=button onclick=add() value=add>
<input type=button onclick=del() value=del>
<div id=ttt></div>
<script language="javascript">
<!--
function add(){//创建
if (!document.getElementById("ttt_div")){//如果"ttt_div"不存在
//创建一个DIV
var addDIV=document.createElement("div")
//设定属性
addDIV.id="ttt_div"
with(addDIV.style){
width="200px"
height="160px"
border="1px red solid"
background="#eee"
}
//向DIV加入一些内容,例如文本框:
addDIV.innerHTML="<input value='创建一个DIV'onmouseover='this.value=\"\"'>"
//将DIV放到"ttt"中
document.getElementById("ttt").appendChild(addDIV)
}
}
function del(){//删除
var obj=document.getElementById("ttt_div")
if (obj)//如果"ttt_div"存在
document.getElementById("ttt").removeChild(obj)//在"ttt"中删除DIV
}//-->
</script>
L@_@K DHTML参考手册.rar
http://download.csdn.net/source/308913