已解决

【精华】如何加入树中啊已解决

学员:徐豫锋提问时间:2008-06-21 09:51:02

应该是没加入控件树的问题吧?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function ok() {
var p=document.createElement("p");
p.innerHTML="添加的内容";
alert("添加段落成功");
}
</script>
</head>
<body>
<script type="text/javascript">
ok();
</script>
</body>为什么不显示啊内容啊?

采纳为答案

回答人:姜昊回答时间:2008-06-25 14:14:06

function ok() {
var p=document.createElement("p");
document.body.appendChild(p);
p.innerHTML="添加的内容";
alert("添加段落成功");
}
需要将新建的DOM对象添加到HTML中

学员对该答案的评价 谢谢

其他回答