<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
$(this).hide()
隐藏当前的 HTML 元素。
$("#test").hide()
隐藏 id="test" 的元素。
$("p").hide()
隐藏所有 <p> 元素。
$(".test").hide()
隐藏所有 class="test" 的元素。
文档就绪函数
$(document).ready(function(){
--- jQuery functions go here ----
});
这是为了防止文档在完全加载(就绪)之前运行 jQuery 代码。
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<button type="button">Click me</button>
</body>
</html>