Home >Web Front-end >JS Tutorial >The problem of mixing setInterval, setTimeout and jquery_jquery

The problem of mixing setInterval, setTimeout and jquery_jquery

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

Method 1. Calling other methods directly in ready will prompt a missing object error. Applying the jQuery extension can solve this problem.

Copy code The code is as follows:

$(document).ready(function(){

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

Method 2. Do not use quotation marks and parentheses when specifying a function to be executed regularly.

Copy code The code is as follows:

function show(){
alert("ready ");
}
setInterval(show ,3000);// Note that the function name does not have quotes or brackets!
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