jQuery实现伸展与合拢panel的方法
本文实例讲述了jQuery实现伸展与合拢panel的方法。分享给大家供大家参考。具体实现方法如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>jQuery伸展与合拢的Panel演示</title>
<styletype="text/css">
*{margin:0;padding:0;}
body{font-size:13px;line-height:130%;padding:60px}
#panel{width:300px;border:1pxsolid#0050D0}
.head{padding:5px;background:#96E555;cursor:pointer}
.content{padding:10px;text-indent:2em;
border-top:1pxsolid#0050D0;display:block;
}
</style>
<scriptsrc="jquery-1.6.2.min.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(function(){
$("#panelh5.head").toggle(function(){
$(this).next("div.content").slideUp();
},function(){
$(this).next("div.content").slideDown();
})
})
</script>
</head>
<body>
<divid="panel">
<h5class="head">点击这里</h5>
<divclass="content">
展开和收起的内容!展开和收起的内容!展开和收起的内容!
展开和收起的内容!展开和收起的内容!展开和收起的内容!
展开和收起的内容!展开和收起的内容!
</div>
</div>
<div>https://www.nhooo.com/</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。