There're many ways to do this. The most simplest method:
var element = $('#my-div');
function myFunction() {
alert('I am here!');
}
$(window).scroll(function(){
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
if ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)) {
myFunction();
}
});
Also there're jQuery Appear plugin and Waypoints plugin:
$('#my-div').appear(function() {
alert('I am here!');
});
$('#my-div').waypoint(function() {
alert('I am here!');
});