-1

I have a div element in html page located at position 1200px from top,now when user scroll page down or up and the div element is showing to user then a javascript function should call . and when again the page is scrolled up/down so that div is not visible then another function must be called.

Alex Gill
  • 1,768
  • 1
  • 13
  • 18
Shakir.iti
  • 93
  • 1
  • 2
  • 13

1 Answers1

0

Use jQuery...

Snippet:

var $yourDiv = $('.your-div');

$(window).scroll(function(){
   if ($(this).scrollTop() > 1200) {
     $yourDiv.fadeIn();
   } else {
     $yourDiv.fadeOut();
   }
});

API references:

Example:

http://jsfiddle.net/gilla/rqz86z3u/2/

Alex Gill
  • 1,768
  • 1
  • 13
  • 18