1.innerText和innerHtml的区别
innerHTML,是在块中加html代码;innerText 在块中加文字。 (注意大小写)!!!!!!
2、getElementById("a").innerHTML="";
getElementById("a").value="";
有value属性的标签才能使用getElementById().value------这个被我证实是错误的!
.value是一个介于innerHTML和innerText的效果
既可以显示代码,还可以显示文本
例如:
innerHTML
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<pid="demo">My First Paragraph.</p>
<script>
document.getElementById("demo").innerHTML="<h1>My First JavaScript</h1>";
</script>
</body>
</html>
输出结果:
MyFirstWebPage
MyFirstJavascript
innerText
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<pid="demo">My First Paragraph.</p>
<script>
document.getElementById("demo").innerText="<h1>My First JavaScript</h1>";
</script>
</body>
</html>
输出结果:
My First Web Page
<h1>My First Javascript</h1>
value
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<pid="demo">My First Paragraph.</p>
<script>
document.getElementById("demo").value="<h1>My First JavaScript</h1>";
</script>
</body>
</html>
输出结果:
My First Web Page
My First Paragraph.