Joe Joe - 3 months ago 7
HTML Question

redirect after few second on click jquery

i have a small issue, i want to redirect page on click using jquery
here is my code

$('#submit').click(function(){
window.location.href='index.php';
})


Now is there any way to delay redirect for 5 second.. i mean when click on button user wait at least 5 second on same page and then redirect to index.php i also tried this but it's not working

$('#submit').click(function(){
window.location.href='index.php';
} 5000)

Answer

Try this:

$('#submit').click(function()
{
    setTimeout(function(){ window.location.href='index.php'; }, 5000);       
});
Comments