In this tutorial we will learn how to redirect to another page after specified time using jQuery.
Here we will use setTimeout to redirect to another page after specified time like 2 second, 5 second , 10 second, 15 second etc.
Let's see example -
How to redirect to another page after specified time using jQuery
<!DOCTYPE html>
<html>
<head>
<title>How To Redirect To Another Page After Specified Time Using jQuery</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
<button class="redirectButton">Click me to Redirect after specified time</button>
<script>
$(".redirectButton").click(function(){
$(this).text('Redirecting soon....');
var delay = 3500;
var url = 'https://www.teknowize.com/'
setTimeout(function(){ window.location = url; }, delay);
})
</script>
</body>
</html>