The difference between $ (""). Data ([Key],[value]) and $.data (Element,[key],[value]):
$.data (Element,[key],[value]) adds cached data to element in a way that distinguishes between two forms of object: JS object, Dom element.
1. If you add cached data for a JS object, jquery encapsulates the cached data in a new object and assigns the new object to a specific attribute of the JS object above (for example: jQuery164007486486807465553). This means that the cached data is eventually stored in the JS object itself.
2. If you are adding cached data for DOM elements, jquery will also encapsulate the cached data in a new object, but place the new object in a global cache and place the index in the DOM element. When you want to get the cached data, simply use this index to find the appropriate object in the cache.
and $ (""). Data ([Key],[value]) is specifically used to add caches for the DOM elements selected by the jquery selector, or to add cached data specifically for DOM elements. We know that the result of the jquery selector is a collection, $ (""). Data ([Key],[value]) assigns the cached data to each element of the collection, and he first converts the elements in the collection from the JQuery object form to the normal DOM object, and then calls the $.data (Element,[key],[value]).