Click here to Skip to main content
Click here to Skip to main content

JQuery Timer

By , 8 May 2013
 

Introduction

You might need a timer during a web development project.

Using the Code

Just use the code or modify according to your project requirement.

Example of page:

HTML

<div class="container">
      <input type="text" id="timer" name="timer" value="" readonly="true"> <br/>
      <div style="margin:0 auto; width: 150px;">
          <div class="button" id="timerStart" style="display: inline;" >Start</div>
          <div class="button" id="timerStop" style="display: inline;" >Stop</div>
          <div class="button" id="timerReset" style="display: inline;" >Reset</div>
      </div>
  </div>   <span style="font-size: 9pt;"> </span>

CSS

.container {
    margin<span class="code-none">: 20px auto<span class="code-none">;
    width<span class="code-none">: 190px<span class="code-none">;
    padding<span class="code-none">: 20px<span class="code-none">;
    display<span class="code-none">: block<span class="code-none">;
    height<span class="code-none">: 80px<span class="code-none">;
    border<span class="code-none">: 1px solid #ccc<span class="code-none">;
<span class="code-none">}  </span></span></

JavaScript

$(function() {
    $('#timer').runner({
        autostart: true
    });
    
    $('#timerStart').click(function() {
        $('#timer').runner('start');
    });
    
    $('#timerReset').click(function() {
        $('#timer').runner('reset');
    });
    
    $('#timerStop').click(function() {
        $('#timer').runner('stop');
    });
});

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Akshaya Kumar Mishra
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionerror en el estilomemberkrakxp9 May '13 - 8:51 
GeneralMy vote of 1memberAlexey Prosyankin8 May '13 - 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130513.1 | Last Updated 8 May 2013
Article Copyright 2013 by Akshaya Kumar Mishra
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid