//this counts how many images exist
var img_count = $("#gallery_scroller img").length;
//this is a number where I want the clicks to stop working
var limit_count = img_count/3;
var click_count = 1;
if (limit_count > click_count){
$("#down_arrow").click(function(){
click_count++
var css_position = -1*click_count*300;
$('#gallery_scroller img').css('top', css_position);
alert(css_position+' '+limit_count+' '+click_count);
});
};
最後にアラートが表示されるので、クリックするたびに値を確認できます。 click_countがlimit_countよりも大きいにもかかわらず、そのまま続行されます。 if条件では、click_countをlimit_countより大きい実際の数値に置き換えます。Javascript if文が正しく動作しない
はclick_count 'の後にセミコロンを追加します++' –