Below is a tutorial on how to create a counter with JQuery.
A counter can be useful when you want an event to take place within a certain time frame. For instance, you want your visitors to see a message after 10 seconds. That's what this tutorial is going to focus on.
First, add your JQuery library.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function counter(time) {
var interval = setInterval(function() {
time = time - 1;
$("#container").html("Seconds Remaining: " + time);
},1000);
}
$(document).ready(function() {
counter(10);
});
</script>
<div id="container"></div>
I hope this tutorial on creating a timer in JQuery has been helpful. Check out my latest car info app.
No comments:
Post a Comment