学员:徐豫锋提问时间: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中
学员对该答案的评价 谢谢