2011-02-02 25 views
0

私はリストアイテムのカルーセルを持っていますが、私ができるようにしたいのは、ユーザーがリストアイテムをクリックしたときですリスト)をクリックすると、クリックされた項目が左にスクロールして最初の表示位置になります。jquery moveリスト内の最初の表示アイテムにクリックしたカルーセル

ああ、カルーセルを動作させるためにjCarouselプラグインを使用しています。

私はリンクを持っている:でも開始する方法

link

本当にわからない、任意のアイデア?

ありがとうございました!ここで

答えて

0

は(それはイベントやアニメーションをクリックしている)役立つかもしれない私のカルーセル、次のとおりです。

<html> 
    <head> 
     <title></title> 
     <style type="text/css"> 
      #wrapper { width: 300px; overflow: hidden; height: 100px; min-height: 100px; position: relative; margin: 0; padding: 0; } 
      #ul { width: 9999px; height: 100px; position: absolute; margin: 0 auto; padding: 0; text-align: center; } 
      .li { float: left; list-style-type: none; position: relative; margin: 0 auto; padding: 0; } 
     </style> 
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script> 
     <script type="text/javascript"> 
      $(document).ready(function() { 

       for (var i = 24; i > 0; i--) { 
        $('#ul').append('<li class="li" style="z-index: '+i+'"><img src="http://www.jamesgraygallery.com/artimages/Mee%20Kyung%20Shim/slides/Last%20Summer,50x50.jpg" alt="'+i+'" width="100" height="100"</li>'); 
       } 

       $('#ul').css({ //Reset the carousel to the center 
        'left': -($('.li').size()*$('.li').width())/2 
       }); 

       var howMany = $('.li').size(); 
       var halfIt = howMany/2; 
       var merp = $('.li').index('#ul'); 

       $('#right').click(function() { //Right button 
        $('#ul').animate({ 
         left: '-='+($('.li').width()*3) //Move the images 
        }, 500); 
        return false; 
       }); 

       $('#left').click(function() { //Left button 
        $('#ul').animate({ 
         left: '+='+($('.li').width()*3) //Move the images 
        }, 500); 
        return false; 
       }); 

      }); 
     </script> 
    </head> 
    <body> 
     <div id="wrapper"> 
      <ul id="ul"> 

      </ul><br /> 
     </div> 
     <a href="#" id="right">right</a>&nbsp;&nbsp;<a href="#" id="left">left</a> 
    </body> 
</html> 

これは、あなたが始めるのに良い場所でなければなりません。^_^

メモ:これはあなたに必要なクリックアニメーション機能を提供しませんが、私はあなたのためにそれをすべて行うことはできませんか? :)

関連する問題