Home > Web Front-end > JS Tutorial > JS/jQuery implements DIV delay for a few seconds before disappearing or displaying

JS/jQuery implements DIV delay for a few seconds before disappearing or displaying

小云云
Release: 2018-02-22 15:00:55
Original
2867 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 it, I hope it can help everyone.

The example in 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, 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

Related recommendations:

jQuery implements code sharing for swapping positions of buttons in two divs

Three css methods to achieve DIV centering

How to fix div or table at a specified position in css

The above is the detailed content of JS/jQuery implements DIV delay for a few seconds before disappearing or displaying. 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