あなたたちから少し助けが必要です。要素がどこにあるかをチェックしています。最初のifステートメントは機能していますが、そうでない場合は...私はこのようなことを試しましたが、機能しません。
else if(($('.current').prev().hasClass('green')){
alert('Green is Before the current Picture');
}
私はこれを達成したいと思います:緑がクラス「現在」の前にある場合アラート「緑は現在の写真の前にあります」。誰かが私を助けることができますか?ありがとうございました!
これがフィドルです。
私はこのコードを持っています:
var $green=$('.green:not(:nth-child(6))');
$('.greencontroll').click(function(){
if($green.next($('.current').length)){
alert('Green is After the current Picture');
}
else if($green.prev($('.current').length)){
alert('Green is Before the current Picture');
}