JavaScript改变html网页的文本内容
<body> <p id="demo">JavaScript能改变html文本内容</p> <script type="text/javascript"> function myFunction() { x=document.getElementById("demo"); // 找到元素 x.innerHTML="Hello JavaScript!"; // 改变内容 } </script> <button type="button" οnclick="myFunction()">点击这里</button> </body>
代码截图:
演示截图: