Jquery Code For Digital Clock - Jquery

How to create a simple digital clock using jquery?

Snippet Code


  
Rate this page :
  [ 0 votes]

Digital clock is generally a type of clock which is used to display the time in digital. This jquery code helps you to display the time in digital format. Sample code for creating digital clock is given below.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type='text/javascript'> $(document).ready(function() { var currentdate = new Date(); var start=0; function digiclock() { currentdate = new Date(); $('.hour').html(currentdate.getHours()); $('.min').html(currentdate.getMinutes()); $('.second').html(currentdate.getSeconds()); $('.data').css({'padding-left':start+'px'}); start=start+5; } window.setInterval(digiclock,1000); }); </script> <div class="main"> <span class="hour"></span>hrs : <span class="min"></span>mins : <span class="second"></span>secs </div>

Tags


Ask Questions

Ask Question