<!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 type="text/javascript">
window.onload = initAll;
function initAll()
{
document.getElementsByTagName("form")[0].onsubmit = function()
{
return addNode();
}
}
function addNode(){
var inText = document.getElementById("textArea").value;
var newText = document.createTextNode(inText);
var newGraf = document.createElement("p")
newGraf.appendChild(newText);
var docbody = document.getElementsByTagName("body")[0];
docbody.appendChild(newGraf);
return false;
}
</script>
</head>
<body>
<form action="#">
<p><textarea id="textArea" rows="5" cols="30"></textarea></p>
<input type="submit" value="在页面上添加文本"/>
</form>
</body>
</html>
javaScripte添加节点
最新推荐文章于 2022-11-15 17:36:04 发布