【发布时间】:2014-10-23 11:54:08
【问题描述】:
我正在制作一个滑块,一切都很好,除了上一个按钮。 这是我的开始:
<div class="slideshow">
<div id="1" class="slider">
<button class="full prevSlide">-</button>
<button class="full nextSlide">+</button>
</div>
<div id="2" class="slider">
<button class="full prevSlide">-</button>
<button class="full nextSlide">+</button>
</div>
<div id="3" class="slider">
<button class="full prevSlide">-</button>
<button class="full nextSlide">+</button>
</div>
</div>
所以当我第一次点击 + 按钮时,#1 在 #3 之后移动,代码如下:
function showNextSlide(el) {
el.each(function(){
$(this).children("div.slider:first").fadeOut()
.next('div.slider').fadeIn()
.end().appendTo(this);
});
}
但是当我点击 - 按钮时,如何将 #1 移动到 #2 之前? 这是我的上一个按钮的代码:
function showPrevSlide(el) {
el.each(function(){
$(this).children("div.slider:first").fadeOut();
$(this).children('div.slider:last').fadeIn();
$(this).prepend(this);
});
}
我的小提琴:http://jsfiddle.net/yy3js4b4/1/ 提前致谢。
【问题讨论】:
-
你能为此制作一个小提琴吗?
标签: javascript jquery slider slideshow