在jQuery中,每5秒调用一个函数的最简单方法是什么?jQuery,如何每5秒调用一个函数。我正在寻找一种方法来自动改变幻灯片中的图像。我宁愿不安装任何其他第三方插件,如果可能的话。
3 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
window.setInterval(function(){
/// call your function here}, 5000);clearInterval()
暮色呼如
TA贡献1853条经验 获得超9个赞
setInterval(function(){
//code goes here that will be run every 5 seconds. }, 5000);
呼唤远方
TA贡献1856条经验 获得超11个赞
// IIFE(function runForever(){
// Do something here
setTimeout(runForever, 5000)})()// Regular function with argumentsfunction someFunction(file, directory){
// Do something here
setTimeout(someFunction, 5000, file, directory)
// YES, setTimeout passes any extra args to
// function being called}添加回答
举报
0/150
提交
取消
