Toggle display of clock by a button using Jquery

We have seen how to display a real time clock in JavaScript in Part 1. Now we will try to manage the display of the clock by controlling it through a button using JQuery.

Here is the demo

Here is the code.
<head> <script src="//"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#bt").click(function(){ $("#ct").toggle(); }); }); function display_c(){ var refresh=1000; // Refresh rate in milli seconds mytime=setTimeout('display_ct()',refresh) } function display_ct() { var strcount var x = new Date() document.getElementById('ct').innerHTML = x; tt=display_c(); } </script> </head> <body onload=display_ct();> <button id='bt'>Clock</button><br> <span id='ct' ></span> </body> </html>
Date Reference Showing Changing Clock
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer