1. Preface
jquery allows the jquery object to be treated as a temporary "data store Center" where developers can store data in Key-value pairs in jquery objects, and the forest jquery object can remove previously stored data and delete previously stored data. The data stored in the jquery object can be either a basic type value or an array, a JavaScript object, and so on. The data store-related methods supported by JQuery objects are as follows:
1) data (Name,value): Stores the Name:value data pair to the jquery object.
2) data (object): Multiple name:value data pairs are deposited into the jquery object at one time. Where object is a shape like {name:value ...} The object.
3) data (): Gets all the data stored in the jquery object. The method returns a {Name:value ...} form of the object
4) Removedata ([name]): Deletes the data stored in the jquery object with the key name.
5) Removadata ([list]): Delete data for multiple keys listed by list.
In addition to this, the jquery namespace provides some tool methods for data storage, which are used to store data on an element.
1) jquery.data (element,key,value): Stores key:value data on element elements
2) Jquery.data (Element,key): Gets the value that corresponds to the specified key on element.
3) Jquery.data (Element): Gets all key:value pairs on element elements.
4) Jquery.removedata (Element[,key]): delete element specified Keya corresponding data item
5) Jquery.hasdata (Element): Determine if data has been stored on element elements
2. Example
The following code demonstrates the data storage-related methods of jquery
<! DOCTYPE Html>3. Running Results
Methods of jquery data storage