jQuery 抄袭笔记(7) : 收缩展开功能
10 Oct 2011今天这节过后就可以给小站做些特效了:侧栏项目的伸缩。
关于slideToggle()
通过使用滑动效果,在显示和隐藏状态之间切换元素
slideToggle() 方法通过使用滑动效果(高度变化)来切换元素的可见状态。
如果被选元素是可见的,则隐藏这些元素,如果被选元素是隐藏的,则显示这些元素。
slideToggle 相当于 slideDown 和 slideUp 的组合
单击一次是向上收起的话 下一次就是下拉
如果元素已经隐藏,则该效果不产生任何变化,除非规定了 callback 函数。
<!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”>
</span>
<meta http-equiv=“Content-Type” content=“text/html; charset=gb2312″ />
</span>Hello Lazynight!</title>
<script type=“text/javascript” src=“jquery-1.1.3.pack.js”></script>
<script type=“text/javascript”>
$(document).ready(function(){
$(“#head”).click(function(){
$(“#content”).slideToggle(“slow”,function(){
alert(“你信了吧…”);
});
});
});
</script>
<style type=“text/css”>
#head {width:450px;border:1px solid;padding:10px;}
#content {width:450px;height:400px;border:1px solid;padding:10px;}
</style>
</head>
</span>
<div id=“head”>点我就能伸缩!不信你试!</div>
<div id=“content”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
</span>
<meta http-equiv=“Content-Type” content=“text/html; charset=gb2312″ />
<script type=“text/javascript” src=“jquery-1.1.3.pack.js”></script>
<script type=“text/javascript”>
$(document).ready(function(){
$(“#head”).click(function(){
$(“#content”).slideToggle(“slow”,function(){
alert(“你信了吧…”);
});
});
});
</script>
<style type=“text/css”>
#head {width:450px;border:1px solid;padding:10px;}
#content {width:450px;height:400px;border:1px solid;padding:10px;}
</style>
</head>
</span>
<div id=“head”>点我就能伸缩!不信你试!</div>
<div id=“content”>
</span>
IF——Bread
If a picture paints a thousand words,
then why can’t I paint you?
The words will never show the you I’ve come to know.
if a face could launch a thousand ships,
then where am I to go?
There’s no one home but you, You’re all that’s left me to.
And when my love for life is running dry,
you come and pour yourself on me.If a man could be two places at one time,
I’d be with you.
Tommorrow and today, beside you all the way.
If the world should stop revolving spinning slowly down to die,
I’d spend the end with you. And when the world was through,
Then one by one the stars would all go out,
then you and I would simply fly away
</pre>
</div>
</body>
</html></p> </div> 下载源码 转载请注明:[于哲的博客][1] » [jQuery 抄袭笔记(7) : 收缩展开功能][2] [1]: http://lazynight.me [2]: http://lazynight.me/430.html