Home > Article > Web Front-end > What to do if jquery data doesn’t work
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.
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>
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!