Why does IE add a jQuery attribute for server-side element with mouseover handler?

丶灬走出姿态 提交于 2019-12-01 23:58:12

It's the jQuery expando attribute, it's the key in the jQuery.cache object that represents that element's data and events collections.

In your example, in that page jQuery.cache["2"] would give you the same as $("#ctl00_CloseButton").data(), when you add an event handler or data and the object doesn't already have one, it gets a new expando (jQuery.expando) attribute with the next number in the sequence as the value.

The reason this is done is primarily for IE, assigning handlers or data objects directly to the element makes the garbage collector behave very poorly, attaching them with this key, but no direct reference link, there's no loop and the garbage collector behaves much better.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!