jquery how to make an element disappear after a few seconds

青灯夜游
Release: 2022-03-18 14:25:07
Original
2288 people have browsed it

Jquery method to make the element disappear after a few seconds: 1. Use the delay() function to set the delay time; 2. Use the hide(), toggle() or slideDown() function to make the element disappear after the specified delay time. Disappears, the syntax is "element object.delay(delay seconds).hide();"

jquery how to make an element disappear after a few seconds

##The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

jquery makes the element disappear after a few seconds

In jquery, you can use the delay() method and hide() (toggle() or slideDown() method) to make the element disappear after a few seconds

  • delay() function to set the delay time

  • hide(), toggle() Or the slideDown() function makes the element disappear after the specified delay time

Implementation code: disappear after three seconds

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<script src="js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				$("button").click(function() {
					$("p").delay(3000).hide(2000);
				});
			});
		</script>
	</head>

	<body>
		<button>隐藏元素</button>
		<p style="background-color: #FFC0CB;">测试文本</p>
	</body>
</html>
Copy after login

jquery how to make an element disappear after a few seconds

【 Recommended learning:

jQuery video tutorial, web front-end

The above is the detailed content of jquery how to make an element disappear after a few seconds. 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