I'm basically trying to accomplish the following. I want it so 5 seconds after the page loads, it'll set the variable to true.
Once true, it'll proceed to give the alert "true".. for now. If someone tries to click the button before 5 seconds, it'll give the alert false.
You've got the right idea, but you have a minor issue with variable scope. To reduce headaches, it's really best to get away from using the string eval option on setTimeout
(which is shown in tutorials all around the web, I know) and use an anonymous function:
var link;
function loading(){
setTimeout(function(){
link = true;
}, 5000);
}
This way, you'll know exactly where link
is declared and the scope is crystal clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With