How to set a few seconds loop in jquery

WBOY
Release: 2022-01-10 17:36:58
Original
1467 people have browsed it

In jquery, you can use the setInterval() method to set the specified code for a few seconds loop. This method can call functions or calculate expressions according to the specified period in milliseconds until clearInterval() is called or the window is closed, the syntax is "setInterval(call function, time)".

How to set a few seconds loop in jquery

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

How to set a few seconds loop in jquery

The setInterval() method can call a function or calculate an expression according to the specified period (in milliseconds) Mode.

The setInterval() method will continue to call the function until clearInterval() is called or the window is closed. The ID value returned by setInterval() can be used as an argument to the clearInterval() method.

Syntax

setInterval(code,millisec[,"lang"])
Copy after login

Parameter Description

code Required. A function to be called or a string of code to be executed.

millisec Must. The time interval, in milliseconds, between periodic executions or calls to code.

Return value

A value that can be passed to Window.clearInterval() to cancel the periodic execution of code.

Example

       
Copy after login

Output result:

How to set a few seconds loop in jquery

Related video tutorial recommendation:jQuery video tutorial

The above is the detailed content of How to set a few seconds loop in jquery. For more information, please follow other related articles on the PHP Chinese website!

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 Recommendations
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!