I have a div in which there is a number that constantly changes. For instance:
<div id="current">124</div>
Then I have a JavaScript function to grab the data from this field and store it into a JavaScript variable. Because the number constantly changes, I delay the code and store the NEW number (after five seconds) into another variable.
However, when I look at the data stored in both of the variables, they are exactly the same (when the number in the div has changed). How can I change my code to store the content of the div in one variable, and store the content again (but five seconds later) in another variable?
var before = document.getElementById('current').innerHTML;
setTimeout(function(){}, 5000);
var after = document.getElementById('current').innerHTML;