<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>事件</title> </head> <body> <div id="box"> <input type="button" value="按钮4" id="btn4"/> </div> <script> //html事件 function showMsg(){ alert("hello"); } //ie下的dom2级事件 var btn4=document.getElementById("btn4"); btn4.attachEvent('onclick',showMsg); </script> </body></html>
添加回答
举报
0/150
提交
取消