通过调用函数改变其内容:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>

    <script type="text/javascript">
    function changetext(id){
      id.innerHTML="Surprise!"
    }
    </script>
    <h1 onclick="changetext(this)">点我啦</h1>


  </body>
</html>

 输出:

DOM事件-调用函数

点击出现:

DOM事件-调用函数

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-01-08
  • 2021-07-04
  • 2022-01-11
  • 2021-11-24
  • 2021-08-04
猜你喜欢
  • 2021-12-26
  • 2021-11-06
  • 2021-12-25
  • 2021-10-01
  • 2022-12-23
  • 2021-07-25
相关资源
相似解决方案