通过 js 修改 html 的文本内容

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <title>xiao001</title>
 6 </head>
 7 <body>
 8     <h1>this is a js and html code</h1>
 9     <p id = "demo">点击按钮将此处文本替换</p>
10     <button type="button" onclick="my_function()">点我</button>
11 
12     <script type="text/javascript">
13         function my_function() {//替换demo里面的文本内容
14             document.getElementById("demo").innerHTML = "Hello javascript!";
15         }
16     </script>
17 
18 </body>
19 </html>
View Code

相关文章:

  • 2022-12-23
  • 2022-02-15
  • 2021-11-12
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案