如何使用jquery更改特定时间间隔的内容 [英] How to Change the Content on Specific Interval using Jquery

查看:94
本文介绍了如何使用jquery更改特定时间间隔的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML标题标签,其中包含一条消息。现在按照我的要求,我需要每10秒更换一次消息。我的意思是我必须在特定时间间隔内更改标题标签的内容,以便消息这是显示将得到改变..



这是我的HTML ..

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

请帮助我在jquery帮助下获得它。



在此先感谢..

解决方案

这里不需要jQuery,您可以简单地做通过使用 setInterval()
$ p $ setInterval(function(){
$(#dynamicMessage) .html('here is your message');
},10000);

如果您想加载一些动态加载的随机数据,则逻辑必须根据需要。

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

解决方案

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.

这篇关于如何使用jquery更改特定时间间隔的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆