Home > Web Front-end > JS Tutorial > body text

Actual measurement of how jquery data() stores values_jquery

WBOY
Release: 2016-05-16 17:25:10
Original
856 people have browsed it

Today I saw a sentence in Chapter 19 of the JS Definitive Guide, saying that jQuery’s data framework does not store element data as element attributes, but it does need to add a special attribute to the element to associate with the data. But what exactly is jQuery? What kind of special attribute has been added? I haven't researched it yet, but I remember that you can get the value of the data-xxx attribute on the HTML tag through jQuery's data("xxx") method.

The test and results are as follows:

Copy the code The code is as follows:

var $demo1 = $("#demo1");
$demo1.data("x",123);
console.log($demo1.attr("x")); //undefined
$demo1 .attr("data-y","abc");
console.log($demo1.data("y")); //"abc"
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