setInterval with a function PARAMETER of global variable not working
https://jsfiddle.net/jsfiddle135/xpvt214o/956977/
Symptom: setInterval works fine with a global variable WITHOUT ANY parameter.
But with a function parameter, the global variable is not passed as a function
parameter.
-------------------------
$(document).ready(function(){
var str; str=""; var num;
function display(num){ // NOT WORKING
function display(){ // Fine
num++;
str=str+num
$("#textid").text(str);
}
setInterval(display, 1000, num);
// NOT WORKING
setInterval(display, 1000);
// Fine
$("#btn").click(function(){
num = 100;
});
});