Hansal Mehta
Hansal Mehta

Reputation: 195

How to Change the Content on Specific Interval using Jquery

I have a Heading tag of HTML which contains a message.Now as per my requirement i need to change the message on every 10 Seconds.I mean i have to change the content of the heading tag on specific interval so that the message that is displaying will get change..

Here is my HTML..

<h1 id="dynamicMessage">Responsive Page<br/><span>Message1</span></h1>

Please help me to get it by the help of jquery..

Thanks in advance..

Upvotes: 0

Views: 760

Answers (2)

Amy
Amy

Reputation: 4032

Try using following code.

window.setInterval(function(){
  $("#dynamicMessage").html("Your Text");
}, 10000);

Enjoy :)

Upvotes: 1

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67207

There is no need for jQuery here, you can simply do that by using setInterval() like,

setInterval(function(){ 
  $("#dynamicMessage").html('here is your message');
}, 10000);

If you want to load some random data which are loaded dynamically, then the logic must be different according to the need.

Upvotes: 2

Related Questions