为什么给button的onclick属性赋值已经定义好的函数会不行呢
<body> <input type="button" value="按钮" id="btn"> <script> function showM() { alert('Hello'); } var btn=document.getElementById("btn"); btn.onclick=showM(); </script> <body>
<body> <input type="button" value="按钮" id="btn"> <script> function showM() { alert('Hello'); } var btn=document.getElementById("btn"); btn.onclick=showM(); </script> <body>
2016-03-05
举报