以下是 jQuery鼠标点击动画弹出图片菜单js代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!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鼠标点击动画弹出图片菜单 </title>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<style type="text/css">
*{margin:0;padding:0;font-family:'微软雅黑';}
/* top */
.top{width:1002px;height:50px;margin:0 auto;border-bottom: 1px solid #D6D6D6;position:relative;overflow:hidden;}
.top span{text-align:center;line-height:50px;width:100%;height:50px;display:block;cursor:pointer;}
.top .imgbox{width:1002px;height:190px;margin:0 auto;text-align:center;padding:20px 0 20px 0;}
.top .imgbox img{margin:0 2px;padding:0;width:94px;height:53px;}
</style>
</head>
<body>
<div class="top">
<span>点击展开</span>
<div class="imgbox">
<img src="images/01.jpg" />
<img src="images/02.jpg" />
<img src="images/03.jpg" />
<img src="images/04.jpg" />
<img src="images/05.jpg" />
</div>
</div>
<script type="text/javascript">
$('.top span').click(function(){
var spanhtml = $('.top span').html();
if(spanhtml=="点击展开"){
$('.top span').html('点击收起');
$('.top').animate({
width:'100%',
height:'200px'
},200);
//图片展开
$('.top .imgbox img').animate({
width:'188px',
height:'105px'
},200);
}else{
$('.top span').html('点击展开');
$('.top').animate({
width:'1002px',
height:'50px'
},200,function(){
//图片缩小
$('.top .imgbox img').animate({
width:'94px',
height:'53px'
},200);
});
}
});
</script>
</body>
</html>