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 realize automatic hiding for five seconds by jquery

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "jquery how to achieve five-second auto-hiding". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "jquery how to achieve five-second auto-hiding".

Two methods: 1. "setTimeout (function () {specify object .hide ();}, 5000);" statement, which achieves the delay effect by setting a timer. 2. Use the "specify object .delay (5000). FadeOut ();" statement to achieve the effect by delaying the execution time of the code.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Jquery realizes automatic hiding for five seconds

1. Use the setTimeout () method

Execute the function () method after setting it for 5 seconds using the setTimeout () method

Within the function () method, use the hide () method to implement the specified element.

$(document) .ready (function () {$("button") .click (function () {setTimeout (function () {$("div"). Hide ();}, 5000);});})

Description:

The setTimeout () method is used to call a function or evaluate an expression after a specified number of milliseconds.

SetTimeout () executes code only once. If you want to call multiple times, use setInterval () or have code itself call setTimeout () again.

2. Use delay () to set the automatic hiding of elements for five seconds

The delay () method sets the delay for the execution of the next item in the queue.

.block {width: 200px; height: 200px; background: brown; cursor: pointer; transition: 0.8s } $(document) .ready (function () {$("button") .click (function () {$("div") .delay (5000) .fadeOut () );})

Hide div elements for 5 seconds

Thank you for your reading, the above is the content of "how to achieve five-second automatic hiding in jquery". After the study of this article, I believe you have a deeper understanding of how to achieve five-second automatic hiding in jquery. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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