画像のIDが必要で、さらに処理を行う2つのシナリオがあるかもしれません.
最初のシナリオウィンドウのスクロール時に何かを実行したい。この場合、スクロール イベントにハンドラーを追加するだけです。
$(window).scroll(function() {
var windowTop = $(this).scrollTop(),
image = $('#listimages').find('img').filter(function(){
return $(this).offset().top < windowTop+100;
//i am adding 100 in windowTop as we can consider the the image as cuurent image even if it is little bit below than top of window.
});
//now you can directly use image if you want to manipulate it.
//if you want id you can get it by
var id=image[0].id //or image.attr('id');
});
2 番目のシナリオ、任意のイベントのトリガーで何らかのアクションを実行する場合。
function currentImg(){
var windowTop = $(this).scrollTop(),
image = $('#listimages').find('img').filter(function(){
return $(this).offset().top < windowTop+100;
});
return image[0].id;
}
ただし、scroll、mousemove などのイベントを追加することはより頻繁に実行されるため、必要になるまであまり使用しないことをお勧めします。