hide() 涵數,隱藏了HTML文件中所有<p>元素。
fadeIn 有點像飛入顯示的效果,也可以直接用$("p").show("100")代替。
toggle 可以直接切換顯示隱藏效果。
<html>
<head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn1").click(function(){
$("p").hide("100");
});
$("#btn2").click(function(){
$("p").fadeIn("100");
});
$("#btn3").click(function(){
$("p").toggle();
})
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button id="btn1" type="button">Click me</button>
<button id="btn2" type="button">show me</button>
</body>
</html>
參考:
$(this).hide() 隱藏當前的 HTML 元素。
$("#test").hide() 隱藏 id="test" 的元素。
$("p").hide() 隱藏所有 <p> 段落的元素。
$(".test").hide() 隱藏所有 class="test" 的元素。
$("p.test").hide() 隱藏所有 class="test" 的段落。
$("#test").hide() - 隱藏所有 id="test" 的元素。
留言列表