Home >Web Front-end >JS Tutorial >JS/jQuery implements DIV delay for a few seconds before disappearing or displaying
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='javascript' type='text/javascript'> $(function () { setTimeout(function () { $("pid").show(); }, 6000); }) </script>2. The second method (
delay)
<script language='javascript' type='text/javascript'> $(document).ready( function() { /** *1.delay函数是jquery 1.4.2新增的函数 *2.hide函数里必须放一个0,不然延时不起作用 */ $('#pid').delay(6000).hide(0); } ); </script>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!