Home > Web Front-end > JS Tutorial > How to implement timed hiding of dialog boxes in jQuery

How to implement timed hiding of dialog boxes in jQuery

亚连
Release: 2018-06-06 10:05:32
Original
1481 people have browsed it

This article mainly introduces the method of jQuery to implement timed hiding dialog box. It analyzes the related functions, implementation methods and operation precautions of jQuery timed hiding dialog box in detail in the form of examples. Friends in need can refer to the following

The example in this article describes how jQuery implements timed hiding of dialog boxes. Share it with everyone for your reference, the details are as follows:

The following content may not be completely correct, it is only for reference when you have questions.

1. setTimeout

: There is a situation where the time is set but the program is executed immediately.

: Whether it is window.setTimeout or window.setInterval, parameters cannot be taken when using the function name as the calling handle.

: The solution is to define an anonymous function

setTimeout(function(){$j('#pre'+ID).fadeOut()},12000);
Copy after login

: The second parameter is the number of milliseconds, 1 second = 1000 milliseconds

Other situations: Introduction to this URL: http: //www.jb51.net/article/36681.htm

2. Set the hiding of the dialog box

Common method one:

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

Commonly used method two:

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

Introduction to the reference website: http://www.jb51.net/article/135028.htm

##3. The difference between fadeOut and hide

hide's hidden effect is to slowly fold and shrink from bottom to top or from bottom right to top left, while fadeOut's fade out effect is to fade out as a whole until it disappears (I don't have it) See the difference)

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

Related articles:

How to use iconfont font icon in webpack

How to implement a circular progress bar in WeChat applet

Implement dynamic introduction of files in webpack

The above is the detailed content of How to implement timed hiding of dialog boxes 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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template