Home > Web Front-end > JS Tutorial > body text

The problem of mixing setInterval, setTimeout and jquery_jquery

WBOY
Release: 2016-05-16 17:37:59
Original
887 people have browsed it

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!
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!