简单的事件处理
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <a href="http://www.itcast.cn">传智播客</a><br /> <input type="button" value="手动的触发 a 的点击操作" id="btn" /> <script> var a = document.getElementsByTagName('a')[0]; var f1 = function (e) { alert(1); } var f2 = function (e) { alert(2); } var f3 = function (e) { alert(3); /*移除浏览器默认行为*/ e.preventDefault(); } /*添加事件*/ a.addEventListener('click', f1); a.addEventListener('click',f2); a.addEventListener('click',f3); /*移除是啊金*/ a.removeEventListener('click',f3); </script> </body> </html>