Home  >  Article  >  Web Front-end  >  What does data in jquery mean?

What does data in jquery mean?

WBOY
WBOYOriginal
2022-01-10 16:57:073471browse

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)".

What does data in jquery mean?

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

  • ##key Optional. String type The specified key name string.

  • value Optional. Object type Any type of data that needs to be stored.

Recommended related video tutorials:

jQuery video tutorial

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn