I want to keep track of a count
variable inside the callback function for setInterval
but the incremented value does not seem to pass down after each call. Here is my code:
var count = 0;
function open_link(count) {
$("a")[count].click();
count++;
}
setInterval(open_link, 5000, count);
I was expecting that count
will be 0, 1, 2 and so on but the value of count
always stays 0. How can I update it?
Thanks.