Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Display Current Time on Webpage using Asp.net

Oct 14, 2012
Introduction

Here I will explain how to show or display current time on webpage or website in
jQuery.

Description:
  
In previous articles I explained Get Current Datetime,
Auto refresh page , Expand textbox on focus ,Disable right click on image and many articles relating to JQuery. Now I will explain how to show or display current time on webpage using jQuery.

To display current time on website or webpage using jQuery we need to write the following code


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>jQuery display current time on webpage</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
ShowTime();
});
function ShowTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = dt.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000); // Here 1000(milliseconds) means one 1 Sec  
}
</script>
</head>
<body >
<form id="form1" runat="server">
<div>
jQuery Display time second by second.
<label id="lblTime" style=" font-weight:bold"></label>
</div>
</form>
</body>
</html>
Live Demo



jQuery Display time second by second.


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email
© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.