This article describes the relevant information about Jquerydata (), Jquerystop (), and jquerydelay () functions one by one. For more information, see jquery data () functions.
In jQuery, the data () function is used to append data to the selected element or obtain data from the selected element. The data accessed through the data () function is temporary data. Once the page is refreshed, the previously stored data will no longer exist.
I. Functions of jquery data ()
The data () method attaches data to the selected element or obtains data from the selected element.
The data accessed through the data () function is temporary data. Once the page is refreshed, the previously stored data will no longer exist.
This function is a jQuery object (instance ). To remove data stored using the data () function, use the removeData () function.
Ii. Usage of jquery data
1. Get the value of the additional data
$ (Selector). data (name)
Parameter description
Name:
Optional. Specifies the name of the data to be retrieved.
If no name is specified, the method returns all stored data from the element as an object.
2. append data with name and value as the object
$ (Selector). data (name, value)
Parameter description
Selector: the object to be appended or to obtain data.
Name: the name of the data.
Value: the value of the data.
3. Use an object to attach data to an element
Use an object with a name/value pair to add data to the selected element.
In addition to assigning values by providing names and values, we can also directly pass in another object ("another") as a parameter. In this case, the attribute names and attribute values of "another" are considered as multiple key-value pairs, and the extracted "name" and "value" are copied to the cache of the target object.
$ (Selector). data (object)
Parameter description
Object: required. Specifies the object that contains the name/value pair.
Instance