HTML,JavaScript,document.getElementById("demo").innerHTML怎么用?
<!DOCTYPEhtml><html><body><h1>MyWebPage</h1><pid="demo">AParagraph.</p><divid="myDIV"...
<!DOCTYPE html>
<html>
<body>
<h1>My Web Page</h1>
<p id="demo">A Paragraph.</p>
<div id="myDIV">A DIV.</div>
<script>
document.getElementById("demo").innerHTML="Hello World";
document.getElementById("myDIV").innerHTML="How are you?";
</script>
</body>
</html>
运行结果:
My Web Page
Hello World
How are you?
,为什么不是先显示:A Paragraph.和A DIV之后再改变成
My Web Page
Hello World
How are you? 展开
<html>
<body>
<h1>My Web Page</h1>
<p id="demo">A Paragraph.</p>
<div id="myDIV">A DIV.</div>
<script>
document.getElementById("demo").innerHTML="Hello World";
document.getElementById("myDIV").innerHTML="How are you?";
</script>
</body>
</html>
运行结果:
My Web Page
Hello World
How are you?
,为什么不是先显示:A Paragraph.和A DIV之后再改变成
My Web Page
Hello World
How are you? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询