これと非常によく似た質問があります。再バインドしますが、解決策がわかりません。
HTMLコンテンツを左右にスライドするためのカルーセルがあります...コンテンツをスライドするための左右の画像があります。カルーセルの終わりに達すると、右側のスライド画像のクリックイベントが解除されます。左の画像をクリックすると、右の画像のクリックイベントが再度バインドされます...以下のように再バインドしても機能しないようです。クリックイベントへの参照を保存する必要があるようですが、正しく取得できません。
$(document).ready(function() {
//when user clicks the image for sliding right
$('#right_scroll img').click(function(){
// code for sliding content to the right, unless end is reached
if($('#carousel_ul li:first').attr('id') == fifth_lli){ // end carousel is reached
$('#right_scroll img').removeAttr('onmouseover');
$('#right_scroll img').removeAttr('onmouseout');
$('#right_scroll img').removeAttr('onmousedown');
$('#right_scroll img').unbind('click');
$('#right_scroll img').attr("src", "Images/gray_next_1.png");
};
});
//when user clicks the image for sliding left
$('#left_scroll img').click(function(){
//if at end of carousel and sliding back to left, enable click event for sliding on the right...
if($('#carousel_ul li:first').attr('id') == fifth_lli){
$('#right_scroll img').attr("src", "Images/red_next_1.png");
$('#right_scroll img').bind('click'); // this doesn't work.
};
});
});