<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> function myAddEvent(obj , ev , fn) { if(obj.attachEvent) { obj.attachEvent("on"+ev,fn); }else{ obj.addEventListener(ev,fn,false); } } window.onload = function(){ var oBtn = document.getElementById("btn"); myAddEvent(oBtn,"click",function(){ alert('a'); }); myAddEvent(oBtn,"click",function(){ alert('b'); }) } </script> </head> <body> <input type="text" id="btn"/> </body> </html>