jquery实现的下拉和收缩效果示例
下拉和收缩类似的效果应用非常的频繁,本章节简单介绍一下如何实现此效果。
代码实例如下:
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<metaname="author"content="http://www.softwhy.com/"/>
<head>
<title>蚂蚁部落</title>
<styletype="text/css">
body{
margin:0auto;
padding:0;
width:570px;
font:75%/120%Arial,Helvetica,sans-serif;
}
a:focus{
outline:none;
}
#panel{
background:#69C7F7;
height:200px;
display:none;
}
.slide{
margin:0;
padding:0;
border-top:solid4px#F27613;
}
.btn-slide{
background:#F27613url(mytest/jQuery/20121225165932118.gif)no-repeatright-50px;
text-align:center;
width:144px;
height:31px;
padding:10px10px00;
margin:0auto;
display:block;
font:bold120%/100%Arial,Helvetica,sans-serif;
color:#fff;
text-decoration:none;
}
.active{
background-position:right12px;
}
</style>
<scripttype="text/javascript"src="http://www.softwhy.com/mytest/jQuery/jquery-1.8.3.js"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active");
returnfalse;
})
})
</script>
</head>
<body>
<divstyle="display:block;"id="panel"></div>
<pclass="slide">
<ahref="javascript:;"rel="externalnofollow"class="btn-slideactive">点击查看效果</a>
</p>
</body>
</html>
以上代码实现了下拉和收缩效果,代码比较简单,这里就不多介绍了。