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

时间:2018-10-11
本文章向大家介绍js通过调用函数改变其内容,需要的朋友可以参考一下

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

<!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>

 输出:

点击出现: