In previous articles I explained Start and Stop timer in JavaScript, Show user current location on google map, Regular expression to validate file upload extension, jQuery Bouncing Menu Example and many articles relating to jQuery, JavaScript. Now I will explain how to use jQuery setTimeout() function with example.
setTimeout(yourfunction(), timeinterval);
function yourfunction() {
// your code here
}
|
setTimeout(function(){// your code here
}, timeinterval);
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript
display current time on webpage</title>
<script type="text/javascript">
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML =
dt.toLocaleTimeString();
setTimeout("ShowCurrentTime()",
1000); // Here 1000(milliseconds) means one 1
Sec
}
</script>
</head>
<body onload="ShowCurrentTime()">
<div>
JavaScript Display current time second by
second:
<label id="lblTime"
style=" font-weight:bold"></label>
</div>
</body>
</html>
|
|
|
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 Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
1 comments :
i live your site