jQuery 隐藏/显示
语法:
$(selector).hide(speed,callback);$(selector).show(speed,callback);
eg1:
<!DOCTYPE html>
<html>
<head>
<script src="
</script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>田红玲,我爱你。</p>
<p>傻逼,田红玲。</p>
<p>滚蛋,田红玲。</p>
</body>
<
eg2:
<!DOCTYPE html>
<html>
<head>
<script src="
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".ex.hide").click(function(){
$(this).parents(".ex").hide("slow");
});
});
</script>
<style type="text/css">
div.ex{
background-color:#e5eecc;
padding:7px;
border:solid 1px #c3c3c3;
}
</style>
</head>
<body>
<h3>我爱你</h3>
<div class="ex">
<button class="hide" type="button">隐藏<
<p>姓名:田红玲 <br />
田大大<br />
田傻逼</p>
</div>
</body>
<ht
jQuery toggle()
使用toggle()方法来切换hide()和show()方法。<!DOCTYPE html>
<html>
<head>
<script src="
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
<button type="button">切换<bu
<p>这是个段落</p>
</body>
<