<html>
<head>
function f(){
document.body.innerText=""+index;
index++;
window.setTimeout("f()",1000);
}
</script>
</head>
<div id="grant"></div>
<body onload="f()">
</body>
</html>对象 grant 的创建 再 执行过程之后。 你把<div id="grant"></div> 放前边就OK了
<head>
function f(){
document.body.innerText=""+index;
index++;
window.setTimeout("f()",1000);
}
</script>
</head>
<div id="grant"></div>
<body onload="f()">
</body>
</html>对象 grant 的创建 再 执行过程之后。 你把<div id="grant"></div> 放前边就OK了
==>
document.getElementById("grant").innerText
<head>
<script type="text/javascript">
function f(){
document.getElementById("grant").innerText=index;
index++;
window.setTimeout("f()",1000);
}
</script>
</head>
<body onload="f()">
<div id="grant"></div>
</body>
</html>
有个问题想请教一下,调用grant.innerText=""+index也没有错,grant不是document一部分吗