Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up a few-second loop in jquery

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today Xiaobian to share with you how to set up a few seconds cycle of jquery related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after some gains, let's learn about it together.

In jquery, you can set a few seconds to loop the specified code using the setInterval() method, which calls a function or evaluates an expression at a specified period in milliseconds until clearInterval() is called or the window is closed, with the syntax "setInterval(call function, time)."

Operating environment for this tutorial: Windows 10 system, jquery version 3.2.1, Dell G3 computer.

How does jquery set up a few seconds cycle

The setInterval() method calls a function or evaluates an expression for a specified period (in milliseconds).

The setInterval() method keeps calling 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"])

parameter description

Code is required. The function to call or the string of code to execute.

Millisec must. The time interval between periodic execution or invocation of code, in milliseconds.

return value

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

examples

var int=self.setInterval("clock()",50)function clock() { var t=new Date() document.getElementById("clock").value=t }

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report