本文介绍如何使用jQuery实现手风琴效果当鼠标悬停的时候展开对应图片
关键jQuery:
jQuery('.sfq ul li.cur').animate({ width: '510px' }, 'slow');
jQuery('.sfq ul li').hover(function () {
var _index = $(this).index();
.stop().animate({ width: '510px' }, 'slow').siblings()
.stop().animate({ width: '230px' }, 'slow').removeClass('cur');
<script>
$(function () {
// 默认展开第一个图片
jQuery('.sfq ul li.cur').animate({ width: '510px' }, 'slow');
jQuery('.sfq ul li').hover(function () {
// 获取li索引
var _index = $(this).index();
$(this).addClass('cur')
.stop().animate({ width: '510px' }, 'slow').siblings()
.stop().animate({ width: '230px' }, 'slow').removeClass('cur');
})
});
</script>
<script>
$(function () {
// 默认展开第一个图片
jQuery('.sfq ul li.cur').animate({ width: '510px' }, 'slow');
jQuery('.sfq ul li').hover(function () {
// 获取li索引
var _index = $(this).index();
$(this).addClass('cur')
.stop().animate({ width: '510px' }, 'slow').siblings()
.stop().animate({ width: '230px' }, 'slow').removeClass('cur');
})
});
</script>