jquery click([data],fn)使用方法實(shí)例介紹
更新時(shí)間:2013年07月08日 17:32:10 作者:
大概意思就是觸發(fā)每一個(gè)匹配元素的click事件,本文通過(guò)一個(gè)實(shí)例為大家詳細(xì)介紹下jquery click([data],fn)的使用方法,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
click([[data],fn])
返回值:jQuery
概述
觸發(fā)每一個(gè)匹配元素的click事件。
這個(gè)函數(shù)會(huì)調(diào)用執(zhí)行綁定到click事件的所有函數(shù)。
參數(shù)
fnFunctionV1.0
在每一個(gè)匹配元素的click事件中綁定的處理函數(shù)。
[data],fnString,FunctionV1.4.3
data:click([Data], fn) 可傳入data供函數(shù)fn處理。
fn:在每一個(gè)匹配元素的click事件中綁定的處理函數(shù)。
示例
描述:
觸發(fā)頁(yè)面內(nèi)所有段落的點(diǎn)擊事件
jQuery 代碼:
$("p").click();描述:
將頁(yè)面內(nèi)所有段落點(diǎn)擊后隱藏。
jQuery 代碼:
$("p").click( function () { $(this).hide(); });以上為JQuery參考手冊(cè)中的內(nèi)容,查閱了很多相關(guān)參考資料,但都沒有對(duì)[data]參數(shù)詳細(xì)說(shuō)明
參數(shù)data是作為event.data屬性值傳遞給事件對(duì)象額外的數(shù)據(jù)對(duì)象
參數(shù)fn是綁定到每個(gè)選擇元素的事件中的處理函數(shù)
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /><title>
JQuery [data]參數(shù)使用說(shuō)明
</title><link href="css/main.css" type="text/css" rel="stylesheet" />
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var message="把該信息傳遞給Fn函數(shù)";
$(".txt").click({msg:message},function(event){$("#idTip").show().html(event.data.msg);});//設(shè)置文本
});
</script>
</head>
<body>
<input class="txt"></div>
<div id="idTip"></div>
</body>
</html>
返回值:jQuery
概述
觸發(fā)每一個(gè)匹配元素的click事件。
這個(gè)函數(shù)會(huì)調(diào)用執(zhí)行綁定到click事件的所有函數(shù)。
參數(shù)
fnFunctionV1.0
在每一個(gè)匹配元素的click事件中綁定的處理函數(shù)。
[data],fnString,FunctionV1.4.3
data:click([Data], fn) 可傳入data供函數(shù)fn處理。
fn:在每一個(gè)匹配元素的click事件中綁定的處理函數(shù)。
示例
描述:
觸發(fā)頁(yè)面內(nèi)所有段落的點(diǎn)擊事件
jQuery 代碼:
$("p").click();描述:
將頁(yè)面內(nèi)所有段落點(diǎn)擊后隱藏。
jQuery 代碼:
$("p").click( function () { $(this).hide(); });以上為JQuery參考手冊(cè)中的內(nèi)容,查閱了很多相關(guān)參考資料,但都沒有對(duì)[data]參數(shù)詳細(xì)說(shuō)明
參數(shù)data是作為event.data屬性值傳遞給事件對(duì)象額外的數(shù)據(jù)對(duì)象
參數(shù)fn是綁定到每個(gè)選擇元素的事件中的處理函數(shù)
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /><title>
JQuery [data]參數(shù)使用說(shuō)明
</title><link href="css/main.css" type="text/css" rel="stylesheet" />
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
var message="把該信息傳遞給Fn函數(shù)";
$(".txt").click({msg:message},function(event){$("#idTip").show().html(event.data.msg);});//設(shè)置文本
});
</script>
</head>
<body>
<input class="txt"></div>
<div id="idTip"></div>
</body>
</html>
您可能感興趣的文章:
- jquery用data方法獲取某個(gè)元素上的事件
- 對(duì) jQuery 中 data 方法的誤解分析
- jQuery中使用data()方法讀取HTML5自定義屬性data-*實(shí)例
- Jquery中ajax方法data參數(shù)的用法小結(jié)
- jQuery $.data()方法使用注意細(xì)節(jié)
- JQuery的html(data)方法與<script>腳本塊的解決方法
- jQuery中index()方法用法實(shí)例
- jQuery中g(shù)et()方法用法實(shí)例
- jQuery中size()方法用法實(shí)例
- jQuery中each()方法用法實(shí)例
- jQuery中data()方法用法實(shí)例
相關(guān)文章
jquery實(shí)現(xiàn)效果比較好的table選中行顏色
這篇文章主要介紹了jquery table選中行顏色實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-03-03jquery獲取iframe中的dom對(duì)象(兩種方法)
本文為大家詳細(xì)介紹下父窗口中操作iframe、在子窗口中操作父窗口,獲取iframe內(nèi)的dom對(duì)象有兩種方法,感興趣的朋友可以了解下哈,希望對(duì)大家有所幫助2013-07-07jQuery EasyUI Accordion可伸縮面板組件使用詳解
這篇文章主要為大家詳細(xì)介紹了jQuery EasyUI Accordion可伸縮面板組件的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02jQuery+PHP實(shí)現(xiàn)微信轉(zhuǎn)盤抽獎(jiǎng)功能的方法
這篇文章主要介紹了jQuery+PHP實(shí)現(xiàn)微信轉(zhuǎn)盤抽獎(jiǎng)功能的方法,詳細(xì)分析了抽獎(jiǎng)程序界面設(shè)計(jì)、前臺(tái)jQuery交互、后臺(tái)概率算法等抽獎(jiǎng)功能相關(guān)技巧,需要的朋友可以參考下2016-05-05jQuery實(shí)現(xiàn)點(diǎn)擊按鈕文字變成input框點(diǎn)擊保存變成文字
這篇文章主要介紹了jQuery實(shí)現(xiàn)點(diǎn)擊按鈕文字變成input框點(diǎn)擊保存變成文字的相關(guān)資料,非常具有參考借鑒價(jià)值,需要的朋友可以參考下2016-05-05