What does data in jquery mean?

WBOY
Release: 2022-01-10 16:57:07
Original
3349 people have browsed it

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 )
Copy after login

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');
Copy after login

Usage 2

$.data( element, key )
Copy after login

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 ));
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!