通過調用函數改變其內容: 輸出: 點擊出現: ...
通過調用函數改變其內容:
<!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>
輸出:
點擊出現: