2011-02-26 42 views
0

我在看教程http://jqueryfordesigners.com/jquery-infinite-carousel/。我試圖創造類似的東西來理解,結果比我想象的要複雜。我如何使用scrollLeft?jQuery scrollLeft

我創建了一個簡單的小提琴測試http://jsfiddle.net/sryKu/2/

<div id="carousel"> 
    <div class="wrapper"> 
     <ul> 
      <li><a href="#">Test Link 1</a></li> 
      <li><a href="#">Test Link 2</a></li> 
... 

CSS

#carousel .wrapper { 
    position: relative; 

ul { 
    position: absolute; 

JS

$wrapper.scrollLeft(itemsPerPage * itemWidth); 

但它不是滾動

回答

1

你將不得不使用animate方法爲:

$wrapper.animate({scrollLeft: itemsPerPage * itemWidth});