In jquery, data means "data". The data() function is used to access data on the specified element and return the setting value. The data accessed through this function is temporary data. Page The data stored after refreshing will be removed, and the syntax is "$.data(element,key,value)".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
What does data in jquery mean
$.data() function is used to access data on the specified element and return the settings value.
Tips: 1. This is a low-level method, and the .data() method is more convenient to use.
2. The data accessed through the data() function is temporary data. Once the page is refreshed, all previously stored data will be removed.
3. This method currently does not provide cross-platform settings on XML documents. Internet Explorer does not allow appending data through custom attributes in XML documents.
Syntax
Usage 1
$.data( element, key, value )
Note: 1. The data accessed through the data() function are temporary data. Once the page is refreshed, all previously stored data will be was removed.
2. undefined is an unrecognized data value. Calling jQuery.data( el, "name", undefined ) will return the corresponding "name" data, which is equivalent to jQuery.data(el, "name" ) .
We can set different values on an element and get these values:
jQuery.data(document.body, 'foo', 52); jQuery.data(document.body, 'bar', 'test');
Usage 2
$.data( element, key )
We can set different values on an element and get these values Get these values:
alert(jQuery.data( document.body, 'foo' )); alert(jQuery.data( document.body ));
Parameter Description
element Element type DOM object to store data
The above is the detailed content of What does data in jquery mean?. For more information, please follow other related articles on the PHP Chinese website!