I have a jquery app which consist of a table. The table has a time field and some number fields. I want to basically increment the values every 3 seconds. So i was thinking of creating a function where i increment the number values and calling it via refresh functions that auto refreshes every 3 seconds.
so basically originally the information is as follows
Kobe Bryant 10:00 30 4 2
after 3 seconds it should be
Kobe Bryant 10:03 31 5 4
This is the Fiddle i have made.
I was not able to do this. I tried to make a function where i increase the table values and call that function as such
setInterval(updateFunction, 3000);
but no luck. This is how i was thinking of creating a function.
var cell = $("#example");
var currentVal = parseInt(cell.text(), 10);
cell.text( currentVal + 1 );
Can anyone please provide some advice. I am new to js and jquery and also sorry for poor english if its hard to understand i can clarify what i mean.
Here is a way. Add classes to the cells that need updating:
In this example, the class updateMeInt means it is a simple integer, and updateMeTime means it is a time value.
Then your update function would iterate through each cell with these classes and increment:
Try this code on interval function:
JSFiddle