Cha*_*son 6 html jquery internet-explorer-8
我正在使用IE8和jQuery 1.4.2.我的网页不再正确呈现,并且在HTML的调试器中快速查看每个元素现在都有一个名为"jQuery1279875396122"的新属性,其值是一个小整数,显然对每个节点都是唯一的.
看看jQuery源码我可以看到长号来自(新日期).getTime(),但这是我理解的极限而没有更多的研究.
我不知道这是否与我的渲染问题有关,但我以前从未注意到它,在IE8或任何其他浏览器中.有人能解释一下这些属性是什么吗?
Jam*_*mes 11
jQuery使用这些"expando"属性来跟踪与元素相关的数据.jQuery使用其数据API进行事件处理,以及您可能希望绑定到元素的任何常规数据(使用$.data).
property(jQuery1279875396122)将具有与位置相关联的值jQuery.cache.
jQuery不直接将数据保存到元素(作为常规属性)的原因是为了避免内存泄漏,而且通常不那么突兀.
举个例子,当你将一个事件处理程序绑定到一个元素时,就像这样:
jQuery('div').click(doSomething);
Run Code Online (Sandbox Code Playgroud)
The doSomething function will be stored in jQuery.cache and, on a rudimentary level, its position (or rather, the position of the object that references it) will be assigned to the element's jQuery1279875396122 property. jQuery will still use the browser's native API to bind to the element's event but when it's fired jQuery will lookup (in jQuery.cache) and call the correct handlers.
EDIT: Just to be clear, these properties are not a cause for concern. You should expect to see them on all elements that have any data bound via jQuery (including event handlers). I would be very surprised if this was the cause of your rendering problem.