Is it possible that if a div is scrolled to, it should execute a function, like for example:
Yes? No?
Is it possible that if a div is scrolled to, it should execute a function, like for example:
Yes? No?
$(window).scroll(function () {
if ($(window).scrollTop() <= $("div#14").position().top && $(window).scrollTop() + $(window).height() >= $("div#14").position().top) {
if ($("div#14").position().top + $("div#14").height() <= $(window).scrollTop() + $(window).height()) {
do_something();
}
}
});
EDIT Sorry, I put the ">=" and "<=" wrong.
Watch it here: http://jsfiddle.net/cBdhk/4/
EDIT 2 I updated the link but forgot updating the code.