【发布时间】:2014-04-02 17:23:14
【问题描述】:
我制作了一个 jquery 幻灯片,代码如下:
HTML
<div id="slideshow">
<img src="1.jpg">
<img src="2.jpg">
<img src="3.jpg">
</div>
<div id="previous">previous</div>
<div id="next">Next</div>
css
#slideshow {
width: 700px;
height: 400px;
position: relative;
overflow: hidden;
}
#slideshow img {
position: absolute;
}
jquery
$(document).ready(function() {
$('#slideshow img:gt(0)').hide();
$('#previous').click(function() {
$('#slideshow img:first').fadeOut(1000).prev().fadeIn(1000).end().appendTo('#slideshow');
});
$('#next').click(function() {
$('#slideshow img:first').fadeOut(1000).next().fadeIn(1000).end().appendTo('#slideshow');
});
});
“下一个”按钮有效,但是当我单击“上一个”时,图像消失了!谁能帮帮我?
这里是fiddle。
【问题讨论】: