0
我試圖做一個形象滑塊,下面是我的代碼:滑塊jQuery中
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>
來tan'下一個'按鈕停止工作。