我正在处理一位旧程序员留下的代码。他用是否jQuery .data返回函数
$.data(item, "onlyIfCheckShow")();
,我想知道如果jquery.data甚至返回的功能。这似乎很奇怪。 下面是数据代码直接从拉的jquery.js:
data: function(key, value){
var parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
if (value == null) {
var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
if (data == undefined && this.length)
data = jQuery.data(this[0], key);
return data == null && parts[1] ?
this.data(parts[0]) :
data;
} else
return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
jQuery.data(this, key, value);
});
}
下面是关于如何'jQuery.data()'作品的解释:http://stackoverflow.com/questions/ 2764619/how-do-jquery-data-work – KushalP 2011-05-09 18:58:25
还有几个问题[(1)](http://stackoverflow.com/questions/3168733/where-does-jquery-datas-method-informatio n-go),[(2)](http://stackoverflow.com/questions/4384784/jquery-data-storage)关于'jQuery.data'如何工作。 – Anurag 2011-05-09 19:53:23