Where is jQuery.data() stored?

前端 未结 3 1425
[愿得一人]
[愿得一人] 2020-11-29 06:45

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

Is there some kind of variable like jQuery.dataDb or somethin

3条回答
  •  青春惊慌失措
    2020-11-29 06:49

    Ok I figured it out.

    jQuery.expando contains a string that's appended to each element which is jQuery + new Date()

    HTMLElement[jQuery.expando] contains the key to that element's data

    jQuery.cache[HTMLElement[$.expando]] contains the data on the element

    Here is a demo

提交回复
热议问题