I want to change the exist in a span element every 2 seconds, but it showing only what is in case 0: ‘asd’.
Could anyone tell me why this is not working?
var n = 0;
function hideVideoSpan(type){
switch(type)
{
case 0:
{
$("#hideVideoSpan").html('asd');
n = 1;
break;
}
case 1:
{
$("#hideVideoSpan").html('lol');
n = 0;
break;
}
default:break;
}
setTimeout(hideVideoSpan(n), 2000);
}
hideVideoSpan(n);
You are calling the function, not making a reference
Needs to be a closure