<!DOCTYPE html> <!--Javascript-DOM EventListener--> <!--添加句柄,就是不需要在Button中调方法了--> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <button id="btn01">按钮01</button> <script> var x = document.getElementById("btn01"); x.addEventListener("click", method01); function method01() { alert("句柄01") } x.addEventListener("click", method02); function method02() { alert("句柄02") } </script> </body> </html>
js基础精华03
最新推荐文章于 2019-10-09 09:48:46 发布