Home > Web Front-end > Front-end Q&A > What to do if jquery data doesn't work

What to do if jquery data doesn't work

藏色散人
Release: 2021-11-22 11:11:59
Original
2101 people have browsed it

Solution to jquery data not working: 1. Open the corresponding code file; 2. Use the "dom.attr('data-hour')" statement, that is, the attr() method to get the attribute value That’s it.

What to do if jquery data doesn't work

The operating environment of this article: Windows7 system, jquery3.2.1, Dell G3 computer.

What should I do if jquery data doesn’t work?

About jQuery's .data() method, it doesn't seem to work after reassignment

I recently used jquery's data method to make a countdown, which is probably like this:

<div data-hour="1" data-minute="0" data-second="0">01:00:00</div>
Copy after login

1) At the beginning, we used the time stored in data, dom.data()

2) Reassign data every second, dom.attr({'data -hour':hour,'data-minute':minute,'data-second':second});

3) Pause

4) Start again, repeat 1) , and then found that the countdown from 1:00:00 started again.

We don’t know why yet, but it has been changed: 1) In 1), use dom.attr('data-hour'), ​​attr() method to get the attribute value

If you know Why, can you tell me, thank you~

Recommended study: "jquery video tutorial"

The above is the detailed content of What to do if jquery data doesn't work. 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