Example of jQuery implementing a countdown jump
- 2020-12-09 00:49:39
- OfStack
Implementation code:
You can copy the code and save it to a file, open the test effects directly with browse, and note the introduction of the jquery.js file.
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title> The jump page </title>
<script src="jquery.js"></script>
<script language="javascript"><!--
$(document).ready(function() {
function jump(count) {
window.setTimeout(function(){
count--;
if(count > 0) {
$('#num').attr('innerHTML', count);
jump(count);
} else {
location.href="http://ofstack.com";
}
}, 1000);
}
jump(3);
});
// --></script>
</head>
<body>
<span style="color:red"> Welcome to ofstack.com ! </span><br/>ofstack.com The page will be 3 Seconds after the jump ...<br/> And then there were <span id="num">3</span> seconds
</body>
</html>
You can copy the code and save it to a file, open the test effects directly with browse, and note the introduction of the jquery.js file.