Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Timed Event

Tags:

jquery

timing

Is it possible, using jQuery, to fire off an event to set a div tag's text after n. seconds?

Thanks! George

like image 748
George Johnston Avatar asked Feb 05 '10 16:02

George Johnston


People also ask

What is the use of delay () method in jQuery?

jQuery delay() Method The delay() method sets a timer to delay the execution of the next item in the queue.

What are JavaScript time events?

Timing events are the events that help to execute a piece of code at a specific time interval. These events are directly available in the HTML DOM (Document Object Model) Window object, i.e., they are present in the browser.

What is timeStamp in jQuery?

timeStamp is an inbuilt property in jQuery which is used to measure difference in milliseconds between the time of event created by the browser and January 1, 1970.


2 Answers

var doIt = function() {
    $("div.my").text("My message");
}
setTimeout(doIt, 3000);
like image 91
Drew Wills Avatar answered Nov 15 '22 18:11

Drew Wills


if you're using jQuery 1.4, you can always do:

$(function() {
   $('#divId').delay(3000).text('New Text');
});

like image 33
Ed James Avatar answered Nov 15 '22 16:11

Ed James