Home > Web Front-end > JS Tutorial > How to make DIV disappear or display after delaying for a few seconds in JS/jQuery

How to make DIV disappear or display after delaying for a few seconds in JS/jQuery

亚连
Release: 2018-06-06 10:07:25
Original
2069 people have browsed it

This article mainly introduces the method of JS/jQuery to realize p to disappear or display after a delay of a few seconds. It analyzes the related operation skills of javascript using setTimeout and jQuery using delay method to realize delayed display function in the form of examples. Friends who need it You can refer to the following

The example of this article describes how JS/jQuery implements the method of p disappearing or displaying after a delay of a few seconds. Share it with everyone for your reference, the details are as follows:

1. The most commonly used method (setTimeout):

<script language=&#39;javascript&#39; type=&#39;text/javascript&#39;>
$(function () {
 setTimeout(function () {
  $("pid").show();
 }, 6000);
})
</script>
Copy after login

2. The second method (delay

jquery makes a p disappear with a delay, pure jQuery, no need for settimeout, just use jQuery to write it.

<script language=&#39;javascript&#39; type=&#39;text/javascript&#39;>
$(document).ready(
 function()
 {
  /**
  *1.delay函数是jquery 1.4.2新增的函数
  *2.hide函数里必须放一个0,不然延时不起作用
  */
  $(&#39;#pid&#39;).delay(6000).hide(0);
 }
);
</script>
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Package and load files to the specified location in webpack (detailed tutorial)

In vue2.0 Making a breadcrumb navigation bar through elementUI

Package js map file in webpack (detailed tutorial)

The above is the detailed content of How to make DIV disappear or display after delaying for a few seconds in JS/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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template