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 Set Some Time Delay for Function / Method Execution with SetTimeout Function

Oct 9, 2013
Introduction

Here I will explain how to execute function in
jQuery with some time delay using setTimeout function or jQuery set some time delay for function or method execution with setTimeout function.
                                                                                   
Description:
  
In previous articles I explained
jQuery get query string parameter value with spaces, jQuery get query string parameter values, jQuery create rounded corners for textbox, jQuery show time in webpage and many articles relating to JQuery. Now I will explain how to get query string parameter value with special characters in jQuery.

Execute function with some time delay

To execute function with some time delay we need to write the code like as shown below


$(function() {
setTimeout("ShowTime()", 1000);
});
If you observe above code ShowTime function will execute after one second delay for complete example check below code

Example:


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

For live demo check below time for every one second function will execute and update the time



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

8 comments :

Francis said...

nice tutorial...

Anonymous said...

hi very nice tutorial.I am new trainee to dotnet.can u please help me how to create a simple C# windows application fully.Am a beginner,so please help me...

devtools.korzh.com said...

Thanks for the useful tutorial!

Kulwant said...

Thanks for the wonderful tutorial.

Anonymous said...

nice

vani said...

by using dropdown list items how to create a excel sheet name ex: if dropdown list item ALL means create a multiple sheetnames one by one.Can you plz give me example

Anonymous said...

hey i am buliding a gps website here i am using a jquery table here each 5 seconds the information in jquery table is updating.so what i need is when it is updating that row should get highlighted.can u help me out

Cross Platform iPhone development Houston TX said...

Appreciates this so much. Keep sharing interesting facts on your next blog.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 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.