0
我試圖使用jQuery實現基本的滑動功能,請找到下面的代碼:滑塊jQuery的不工作
HTML:
<div class="dashboard-crousel" id="spanCarousel">
<span>My Order</span>
<span class="selected">Recommendations</span>
<span>My Profile</span>
<div id="controls">
<a href="javascript:void(0);" class="dashboard-crouselLeftArrow"></a>
<a href="javascript:void(0);" class="dashboard-crouselRightArrow"></a>
</div>
</div>
的Javascript:
<script>
var slider = {
length: parseInt($("#spanCarousel").children("span").length),
current: 1,
width: $("#spanCarousel").width(),
next: function(){
if(this.current < this.length){
this.current = this.current + 1;
this.animation();
} else {
this.current = 1;
this.animation();
}
},
animation: function(){
var target = (0 - this.width) * (this.current - 1);
this.run("#spanCarousel", target);
},
prev: function(){
if(this.current > 1){
this.current = this.current - 1;
this.animation();
} else {
this.current = this.length;
this.animation();
}
},
run: function(part, target){
$(part + " .pan").stop().animate(
{"margin-left": target},
1000
);
},
initialize: function(){
$("#controls .dashboard-crouselLeftArrow").click(function(){slider.next();});
$("#controls .dashboard-crouselRightArrow").click(function(){slider.prev();});
}
}
slider.initialize();
</script>
我只想在圖像中顯示的箭頭之間滑動內容。
我想從左向右移動文字層出不窮。請幫助
問題是什麼? –
它不工作... – Anubhav