jquery中隐藏操作

时间:2022-05-06
本文章向大家介绍jquery中隐藏操作,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>myFirstJquery.html</title>
		<script type="text/javascript" src="jquery.js"></script>
		<script type="text/javascript">
			// $(document).ready(function(){
			// 	$("p").click(function(){
			// 		$(this).hide();
			// 	});
			// });

			$(document).ready(function(){//将函数绑定到文档的就绪事件(当文档完成加载时)
				$("button").click(function(){
					$("#2").hide();//对所以id为2
					$(".3").hide();//对所以的class为3
					$("p.4").hide();//对p的class为4
					// $("p").hide();//对所有p
					$("p").css("background-color","red");
				});
			});
		</script>
	</head>
	<body>
		<div>
			<p>When you click there, the content will dispear1.</p>
			<p id="2">When you click there, the content will dispear2.</p>
			<p class="3">When you click there, the content will dispear3.</p>
			<p class="4">When you click there, the content will dispear4.</p>
			<p>When you click there, the content will dispear5.</p>
			<button type="button">button</button>
		</div>
	</body>
</html>