2010-12-26 9 views
1

スライディングパネルがあり、最後の要素でアニメーションを止めたいのですが、.is( ':last')を使って試してみましたが、停止しません。ここに私のコードです。フォームがロードされると、現在のvarが最初の要素に設定されます。それは左にアニメーション化し、あなたは私だけ最後の要素のアニメーションを停止します

jQuery('.wikiform .navigation input[name^=Next]').click(function() { 
    if (current.is(':last')) return; 
     jQuery('.wikiform .wizard').animate({ marginLeft: '-=' + current.width() + "px" }, 750); 
     current = current.next();}); 

<div id="formView1" class="wikiform"> 
    <div class="wizard"> 

     <div id="view1" class="view"> 
      <div class="form"> 
       Content 1 
      </div>   
     </div> 
     <div id="view2" class="view"> 
      <div class="form"> 
       Content 2 
      </div> 
     </div> 

    </div> 
    <div class="navigation"> 
     <input type="button" name="Back" value=" Back " /> 
     <input type="button" name="Next " class="Next" value=" Next " /> 
     <input type="button" name="Cancel" value="Cancel" /> 
    </div> 
</div> 

答えて

2

代わり:lastの最後の要素でそれを停止したいの横のボタンをクリックしたときに、このような.next()兄弟がある場合、単にチェックアニメーション続けて:

jQuery('.wikiform .navigation input[name^=Next]').click(function() { 
    if (current.next().length == 0) return; 
+0

大変うまくいった – ONYX