bobo JavaScript中innerHTML,innerText,value
.value是一个介于innerHTML和innerText的效果
既不会显示代码,还可以显示文本
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p id="demo">My First Paragraph.</p>
<script>
document.getElementById("demo").innerHTML="<h1>My First JavaScript</h1>";
</script>
</body>
</html>
My First Web Page
My First Javascript
innerText<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p id="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>
<p id="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.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。