div刷新,无需单击按钮 [英] div refresh without click of the button
本文介绍了div刷新,无需单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使div刷新(例如10秒钟后)并执行run_query()函数,而无需单击按钮?
how do i make the div refresh, say after 10 secs and execute the run_query() function without clicking on the button?
<script src="scripts/ajax.js" type="text/javascript"></script>
<div id="quote"><strong>Quote of the Day</strong></div>
<div><a style="cursor:pointer" onclick="run_query()">Next quote …</a></div>
推荐答案
使用 setInterval 函数.
Use setInterval function.
setInterval(function(){run_query();}, 10000);
对于初始加载,您可以从服务器端代码执行此操作.
For the initial load you can do that from the server side code.
这篇关于div刷新,无需单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文