jQuery data()存储 [英] Jquery data() storage

查看:98
本文介绍了jQuery data()存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我jquery data()在哪里存储数据以及何时删除数据以及如何删除数据吗?

Can any one tell me where jquery data() stores the data and when it is get erased and how?

如果使用此存储ajax调用结果,是否存在任何性能问题?

Is there any performance issue if I use this to store ajax call result?

例如:

$("body").data("test", { myData: 'abcd'});

推荐答案

查看jquery的内容

see the content from jquery

jQuery.data()方法允许我们以对循环引用安全的方式将任何类型的数据附加到DOM元素,从而避免内存泄漏. jQuery确保在通过jQuery方法删除DOM元素时以及用户离开页面时删除数据.我们可以为单个元素设置几个不同的值,并在以后检索它们:

The jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore free from memory leaks. jQuery ensures that the data is removed when DOM elements are removed via jQuery methods, and when the user leaves the page. We can set several distinct values for a single element and retrieve them later:

这篇关于jQuery data()存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆