How to refresh a page after 5 seconds with jquery?
When user clicked on a HTML tag i want to reload correct page after 5000 seconds.
i used this code but it doesn't work
$(".btnclose").on("click", function (e) {
location.reload().delay(5000);
});
You can simply use setTimeout
:
setTimeout(function() {
location.reload();
}, 5000);
Note that setTimeout
does not guarantee exact 5 second delay. It is not very accurate.
Like this JSFiddle:
$(".btnclose").on("click", function (e) {
setTimeout(function(){
location.reload();
}, 5000)
});
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