国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JQuery調用綁定click事件的3種寫法

2019-11-20 12:50:58
字體:
來源:轉載
供稿:網友

第一種方式:

 $(document).ready(function(){ $("#clickme").click(function(){    alert("Hello World click"); });

 第二種方式:

 $('#clickmebind').bind("click", function(){ alert("Hello World bind"); });

第三種方式:

$('#clickmeon').on('click', function(){  alert("Hello World on"); }); }); 

注意:第三種方式只適用于jquery 1.7以上的版本
源碼如下:

<!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=gb2312" /><script type="text/javascript" src="js/jquery-1.6.1.min.js"></script><script type="text/javascript" src="js/jquery.validate.js"></script><script type="text/javascript" src="js/jquery.metadata.js"></script><script type="text/javascript" src="js/messages_zh.js"></script><style type="text/css"> #frm label.error { color: Red; }</style></head><script type="text/javascript">$(document).ready(function(){ $("#clickme").click(function(){    alert("Hello World click"); });   $('#clickmebind').bind("click", function(){ alert("Hello World bind"); });$('#clickmeon').on('click', function(){ alert("Hello World on");});});</script><body><label></label><form id="frm" name="frm" method="post" action=""><label>用 戶 名:  <input type="text" name="username" id="username" /></label> <p>  <label>郵    編 :<label></label></label>  <label>  <input type="text" name="postcode" id="postcode" />  <br />  </label> </p> <p><label>數   字 :   <input type="text" name="number" id="number" /> </label>  <br /><label>身份證號:  <input type="text" name="identifier" id="identifier" />  </label>    <label> <input type="button" name="clickme" id="clickme"  value="click me" />  </label>  <label> <input type="button" name="clickmebind" id="clickmebind" value="clickme_bind" /> </label> <label> <input type="button" name="clickmeon" id="clickmeon" value="clickme_on" /> </label> </p></form></body></html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德兴市| 宿迁市| 新宾| 城市| 汾西县| 萨嘎县| 乳山市| 德安县| 黑山县| 巫山县| 凉城县| 孟州市| 离岛区| 陕西省| 高陵县| 钟山县| 西峡县| 茶陵县| 略阳县| 大兴区| 民勤县| 武定县| 长兴县| 长春市| 东海县| 织金县| 海伦市| 鹤壁市| 黔江区| 巴中市| 秦安县| 醴陵市| 赣榆县| 板桥市| 同心县| 华蓥市| 晋城| 屯昌县| 黄冈市| 油尖旺区| 花莲市|