jquery cache data

<div id="a"></div>
<script src="jquery1.7.js"></script>
<script>

$('#a').data({name : 'sdf'});
var a = document.getElementById('a');
$.data(a);
console.log($.cache)

var obj = {};
$.data(obj, 'name', 'sunhaixun')
console.log(obj);

console.log($.cache[a[$.expando]]);

 

</script>

 

 

打印数据

jquery cache data

 

jquery.data 将数据 存储在$.cache 对象中 存贮中将elem[$.expando] = id = ++$.uuid;关联起来,取出的时候

id = elem[$.expando] ; $.cache[id] 就取出值

 

 

转载于:https://www.cnblogs.com/shxydx/articles/2688920.html