标签:
有时候需要让a标签像button一样,被点击的时候触发事件而不跳转页面。
<html> <body> <a id="a1" href="#none" onclick="a_click(this.id)">Click a1</a> <a id="a2" href="javascript:void(0);" onclick="a_click(this.id)">Click a2</a> <a id="a3" href="any.html" onclick="a_click(this.id);return false;">Click a3</a> </body> <script type="text/javascript"> function a_click (aid) { alert(aid + " was clicked."); } </script> </html>
标签:
原文地址:http://www.cnblogs.com/huey/p/4315520.html