I have a simple timer to record the time:
let div = document.querySelector('div')
let interval = window.setInterval(function(){
div.textContent =parseFloat(div.textContent)+1
},1)
<div>0</div>
I found that when I switch to another tab, the setInterval
will not working.
Are there some simple solution to solve this problem?
I do do some research like, people suggest to use window.requestAnimationFrame
, but it doesn’t work as well.
Are there some simple solution or built-in function to solve this (I just want to make a simple timer)?
Thanks for any responds!