返回值:jQuery jQuery.data(element,[key],[value])
概述
在元素上存放資料,返回jQuery對象。
注意:這是一個底層方法。你應當使用.data()來代替。
此方法在jQuery 1.8中刪除,但你仍然可以通過$._data(element, "events")除錯事件資料。請注意,這是不支援的公共介面;實際的資料結構可能會改變從版本之間不相容。
參數
element,key,value String,String,Any V1.2.3
element :要關聯資料的DOM對像
key :儲存的資料名
value :將要儲存的任意資料
element,key String,String V1.2.3
element :要查詢資料的DOM對像
key :儲存的資料名
element String V1.4
要查詢資料的DOM對像
示例
jQuery 程式碼:
jQuery.data(document.body, 'foo', 52);
jQuery.data(document.body, 'bar', 'test');