Home  >  Article  >  Web Front-end  >  setInterval,setTimeout与jquery混用的问题_jquery

setInterval,setTimeout与jquery混用的问题_jquery

WBOY
WBOYOriginal
2016-05-16 17:37:59863browse

方法1. 直接在ready中调用其他方法,会提示缺少对象的错误,应用jQuery的扩展可以解决这个问题。

复制代码 代码如下:

$(document).ready(function(){

$.extend({
  show:function(){
   alert("ready");
  }
});
setInterval("$.show()",3000);
});

方法2. 指定定时执行的函数时不要使用引号和括号。

复制代码 代码如下:

function show(){
   alert("ready");
}
setInterval(show ,3000);// 注意函数名没有引号和括弧!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn