您的位置:首页 > Web前端 > JQuery

jQuery实现伸展与合拢panel的方法

2015-04-30 09:47 501 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>jQuery伸展与合拢的Panel演示</title>
<style type="text/css">
*{margin:0;padding:0;}
body { font-size: 13px; line-height: 130%; padding: 60px }
#panel { width: 300px; border: 1px solid #0050D0 }
.head { padding: 5px; background: #96E555; cursor: pointer }
.content { padding: 10px; text-indent: 2em;
border-top: 1px solid #0050D0;display:block;
}
</style>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#panel h5.head").toggle(function(){
$(this).next("div.content").slideUp();
},function(){
$(this).next("div.content").slideDown();
})
})
</script>
</head>
<body>
<div id="panel">
<h5 class="head">点击这里</h5>
<div class="content">
展开和收起的内容!展开和收起的内容!展开和收起的内容!
展开和收起的内容!展开和收起的内容!展开和收起的内容!
展开和收起的内容!展开和收起的内容!
</div>
</div>
<div>//www.jb51.net/</div>
</body>
</html>

希望本文所述对大家的jQuery程序设计有所帮助。

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jQuery 伸展 合拢