zoukankan      html  css  js  c++  java
  • 绑定按钮点击click事件

    <!--方法一, 建议-->

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> </head> <body> <button type="button" id="buttonid">绑定点击事件</button> <script> $('#buttonid').bind('click', function() { console.log('button has clicked!'); }); </script> </body> </html>

      

    方法二, 建议方法一

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
      </head>
    <body>
    
    	<button type="button" id="buttonid" onclick="clickCallBack()">绑定点击事件</button>
    	
    	<script>
    		function clickCallBack() {
    			console.log('button has clicked');
    		};
    	</script>
    	
    </body>
    </html>
    

      

  • 相关阅读:
    雅礼集训2017day5乱写
    任意值域最长公共子序列问题
    雅礼集训2017day4乱写
    雅礼集训2017day2乱写
    SP839
    雅礼集训2017day1乱写
    CF671E
    仅维护当前区间影响类问题的线段树
    「雅礼集训 2017 Day4」编码
    Codeforces Round #503 Div. 2
  • 原文地址:https://www.cnblogs.com/helloweworld/p/4797519.html
Copyright © 2011-2022 走看看