<!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>animate()函数实现菜单折叠-www.jb200.com</title>
<style>
<!--
.left {
width:100px;
height:500px;
background:#060;
float:left;
}
#butid {
width:10px;
height:500px;
background:#C00;
float: left;
}
.content {
width:500px;
height:500px;
background:#000;
float:left;
color: #FFF
}
-->
</style>
</head>
<body>
<script type="text/
javascript" src="thirdparty/
jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
var i = 1;//设置状态判断
$('#butid').click(function(){
if(i == 1){
$('.content').animate({left: '-=100px',width: '600px'}, "slow");
$('.left').animate({width: '0px'}, "slow");
i = 2;
}else{
$('.content').animate({left: '0px',width: '500px'}, "slow");
$('.left').animate({width: '100px'}, "slow");//fadeOut()
i = 1;
}
});
});
</script>
<div class="left">123</div>
<div id="butid"></div>
<div class="content">123</div>
</body>
</html>