jQuery.data()存储在哪里? [英] Where is jQuery.data() stored?

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

问题描述

jQuery在哪里存储它设置为DOM对象的 data()的值?

Where does jQuery store the values of the data() that it sets to DOM objects?

是有某种变量,如 jQuery.dataDb 或其他东西,甚至可能是私有的?

Is there some kind of variable like jQuery.dataDb or something, maybe even something private?

有没有办法获取对此对象的访问权限?

Is there any way to gain access to this object?

推荐答案

在内部,jQuery创建一个名为 $ .cache的空对象,用于存储通过数据方法设置的值。您向其添加数据的每个DOM元素都会被分配一个唯一的ID,该ID在 $ .cache 对象中用作键。

Internally, jQuery creates an empty object called $.cache, which is used to store the values you set via the data method. Each DOM element you add data to, is assigned a unique ID which is used as a key in the $.cache object.

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

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