2010-04-22 51 views

回答

17
+0

谢谢 - 完美的工作。简单的回答一个简单的问题:) – 2010-04-22 22:57:46

10

的。数据()函数允许你存储或取回数据,并将其与匹配元素相关联。

在许多情况下,使用data()对body标签存储键值对是最容易的。

数据存储例

//Store the string "bar" with the body tag, with the key "foo" 
$('body').data('foo', 'bar'); 

数据检索实施例

//Retrieve the string "bar" 
var str = $('body').data('foo'); 

参考

相关问题