关于innerText简单问题???????????
<html>
<head>
function f(){
document.body.innerText= " "+index;
index++;
window.setTimeout( "f() ",1000);
}
</script>
</head>
<body onload= "f() ">
<div id= "grant "> </div>
</body>
</html>
为什么document.body.innerText= " "+index;就可以有输出
但换成document.grant.innerText= " "+index;没有输出了
这是为什么啊?????????
------解决方案--------------------document.grant.innerText//没这种写法
==>
document.getElementById( "grant ").innerText
------解决方案-------------------- <html>
<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>
------解决方案--------------------document.getElementById( "grant ")
or
window.grant
------解决方案--------------------好像对DIV,不能用document+DIVID,要不就直接用grant.innerText,或document.getElementByID( "grand ").innerText