I am trying to hide an element after 2000ms by the below code.
setTimeout($templateElement.hide(),2000);
I am the new one to jquery and java-script. I hope Anyone clear my doubts.
The code
setTimeout($templateElement.hide(),2000);
executes the $templateElement.hide() immediately and passes its return value (a jQuery object) into setTimeout. You may have meant:
setTimeout(function() {
$templateElement.hide();
}, 2000);
...which passes a function reference into setTimeout, to be called two seconds later. That function then does the hide when it gets called.
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