return false
이 아래의 $.each
루프를 종료하지 않는 이유는 무엇입니까?
var Items = {
"5340071": {
"alt": "Sample text"
},
"5333539": {
"alt": "Sample text"
},
// Etc.
};
var viewportBottom = $(window).height() + $(window).scrollTop();
$.each(Items, function(itemId, objItem) {
$("<img src='/img/1503/4/" + itemId + ".jpg?h=150'>").on('load', function() {
$(document.body).append($(this));
var imageTop = $(this).offset().top;
if (imageTop > viewportBottom) {
console.log('Exit loop'); // Text is printed in console
return false; // This should break the $.each loop, but it doesn't
}
});
});
알려 주시기 바랍니다.
@ T.J.Crowder 'for'에서 작동합니다. '$ .each'에서 작동한다고 가정했습니다. :) – guradio
@guradio : 완전히 다른 것들입니다. –