<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>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有