Steve Steve - 4 months ago 11
jQuery Question

jquery - Compare old and new value after timer

I've been struggeling with this problem for a while. I bet the solution is pretty easy, so here's the point.
I have a number which I update using setinterval.
After this , I want to check if this number is higher or lower than the number before it's refreshed. If it's higher, it has to show an arrow up, or the other way round. (But I got that covered already, just need the comparison)

Here's what I have until now:

setInterval(function () {
var $omzetvandaag = $("#omzetvandaag").text();

$("#omzetvandaag").load("index.php #omzetvandaag");

//some code for the comparison

}, 5000 )


Thanks in advance!

Answer
 var omzetvandaag;
setInterval(function () {

    omzetvandaag = $("#omzetvandaag").text();
    var oldData = omzetvandaag;
    $("#omzetvandaag").load("index.php #omzetvandaag");
   // compare oldData and omzetvandaag
//some code for the comparison 

}, 5000 )
Comments