.click( [eventData ], handler ) eventData Type: Anything An object containing data that will be passed to the event handler. handler Type: Function( Event eventObject ) A function to execute each time the event is triggered.
中文API
更新:简单的栗子
var test_data = {
'key': 'value',
'k': 'v'
};
$("#btn").click(test_data, function (e) {
console.log(e.data); //Object {key: "value", k: "v"}
});
jquery的data其实你把他看做是一个属性就行了,就是存储一些数据之类的东西!
这个支持 @keep_M 的回答,jquery 1.4.3+就可以这样写了。网上例子也不少,自行谷歌。.click() 官方API
中文API
更新:简单的栗子
何不考虑data属性实际情况中的使用呢
第一个参数不是应该是data吗
抱歉,恕我无法理解,这段代码在我看来就是错的