1. 程式人生 > >js點選按鈕改變文字

js點選按鈕改變文字

<!DOCTYPE html>
<html>
<head>
  <script>
    function myFunction()
    {
    document.getElementById("demo").innerHTML="My First JavaScript Function";
    }
  </script>
</head>

<body>
  <h1>My Web Page</h1>
  <p id="demo">A Paragraph.</
p
>
<button type="button" onclick="myFunction()">點選這裡</button> </body> </html>