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

jQuery method to implement timed hiding of dialog boxes

php中世界最好的语言
Release: 2018-03-14 17:35:06
Original
1506 people have browsed it

This time I will bring you the jQuery method to implement a timed hidden dialog box. What are the precautions for the jQuery method to implement a timed hidden dialog box? The following is a practical case, let's take a look.

The following content may not be completely correct, but is only for reference in case of 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, no parameters can 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

2. Set the hiding of the dialog box

Commonly used 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是异步执行的。
    */
    $('#pid').delay(6000).hide(0);
  }
);
Copy after login

3 . The difference between fadeOut and hide

The hide effect is to slowly fold and shrink from bottom to top or from the bottom right to the top left, while the fadeOut effect is to fade out as a whole until it disappears (I No difference is seen)

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Implementation of mouse-responsive transparency gradient effect

How to realize the scroll bar automatically when it slides to the bottom Loading more content

#How to use jquery to create a magnifying glass effect

The above is the detailed content of jQuery method to implement timed hiding of dialog boxes. 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