1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8 <title>Document</title> 9 </head> 10 11 <body onl oad="ready()"> 12 <script> 13 window.onload = function () { 14 document.getElementById("btn").onclick = function () { 15 alert("hello js"); 16 } 17 } 18 </script> 19 <input type="button" value="按钮" id="btn"> 20 </body> 21 22 </html>
标签:function,onload,顺序,代码,javsscript,btn From: https://www.cnblogs.com/2018jason/p/17156762.html