开发者

what is the meaning of jquery random attributes in html ? [expando attribute]

开发者 https://www.devze.com 2023-01-19 23:50 出处:网络
what is the meaning of these jquery random attributes in html and how jquery use them an开发者_运维技巧y ideas please ??This is the jQuery expando attribute, it\'s a bit random because it\'s gener

what is the meaning of these jquery random attributes in html and how jquery use them

what is the meaning of jquery random attributes in html ? [expando attribute]

an开发者_运维技巧y ideas please ??


This is the jQuery expando attribute, it's a bit random because it's generated on page load, it's "jQuery" + (new Date()).getTime() (to avoid possible naming conflicts) but you'll notice the attribute is the same for all elements.

This is they key in $.cache for the element's events and data...it's stored this way for a few reasons, the main is to avoid circular references. The ID is actually $.uuid which is just an incrementing counter used for each element's key in $.cache.

You can get the current attribute in jQuery 1.4+ with a simple alert($.expando), for an example of how it's used, say you wanted the data for that #wmd-preview element, doing this:

$("#wmd-preview").data()

Is doing this:

$.cache[$("#wmd-preview")[0][$.expando]]

Also note that jQuery intentionally strips these out when you call .html() to get the content.

0

精彩评论

暂无评论...
验证码 换一张
取 消