我正在寻找如何滚动到下一个元素:
单击那些大字母,它会在点击和下滑效果后滚动到当前元素。
有我的尝试:(JSFiddle:http://jsfiddle.net/d272P/)
HTML
<div id="head1">Click</div>
<div id="child1">Content</div>
<br/>
<div id="head2">Click</div>
<div id="child2">Content</div>
<br/>
<div id="head3">Click</div>
<div id="child3">Content</div>
CSS
#head1{width: 400px; height: 40px; background: orange;}
#head2{width: 400px; height: 40px; background: red;}
#head3{width: 400px; height: 40px; background: purple;}
#child1{width: 300px; height: 700px; background: green; display: none;}
#child2{width: 300px; height: 700px; background: cyan; display: none;}
#child3{width: 300px; height: 700px; background: pink; display: none;}
的JavaScript
$('#head1').click(function() {
$('#child1').animate({
opacity: 'toggle',
height: 'toggle'
},
{
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'
},
}
);
});
$('#head2').click(function() {
$('#child2').animate({
opacity: 'toggle',
height: 'toggle'
},
{
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'
},
}
);
});
$('#head3').click(function() {
$('#child3').animate({
opacity: 'toggle',
height: 'toggle'
},
{
duration: 750,
specialEasing: {
width: 'linear',
height: 'easeInOutQuad'
},
}
);
});
答案 0 :(得分:1)
答案 1 :(得分:0)
这个功能可以通过使用jquery accordion
来实现