我正在尝试制作图像滑块,以下是我的代码:
HTML
<div class="slider_mian_cont">
<div class="slider_inner">
<ul>
<li><img src="images/one.jpg" width="940" height="350" alt=" " /></li>
<li><img src="images/two.jpg" width="940" height="350" alt=" " /></li>
<li><img src="images/three.jpg" width="940" height="350" alt=" " /></li>
</ul>
</div>
</div>
<div id="next"><a href="#">next</a></div>
jQuery
$(document).ready(function(e) {
var len = $('.slider_mian_cont ul li').length;
var wd = $('.slider_mian_cont ul').width();
var mn = $('.slider_inner').width(wd*len);
var testa = $('.slider_mian_cont ul li').width();
$('#next').click(function(){
var leftValue = $('.slider_inner').position().left;
//console.log('leftValue : ' + leftValue + ', testa : ' + testa);
var movedValue = leftValue - testa;
//console.log('movedValue : ' + movedValue);
$('.slider_inner').animate({ left: movedValue }, 200 )
})
});
CSS
.slider_mian_cont{width:940px; height:350px; overflow:hidden; position:relative;}
.slider_inner{position:absolute;}
.slider_mian_cont ul{margin:0; padding:0; }
.slider_mian_cont ul li{margin:0; padding:0; float:left; width:940px; height:350px; list-style:none;}
我只想设置条件,如果最后<li>
来棕褐色“下一步”按钮停止工作。