div refresh without click of the button

时光怂恿深爱的人放手 提交于 2019-12-23 14:36:10

问题


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>

回答1:


Use setInterval function.

setInterval(function(){run_query();}, 10000);

For the initial load you can do that from the server side code.




回答2:


setTimeout("run_query()",10000);


来源:https://stackoverflow.com/questions/2629327/div-refresh-without-click-of-the-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!