Mossawir Ahmed
Mossawir Ahmed

Reputation: 655

how to show a div when scroll bar goes down, and when i scrollbar goes up it should disappear

i have a website it like 1800px in height. i want when user scrolldown around 200px it show an div on the top of the layout and its should stick with the page. when user scroll back to top , the div should disappear.

Upvotes: 2

Views: 4657

Answers (2)

Ibu
Ibu

Reputation: 43810

You can use the jquery scroll method

$(window).scroll(function () { 
      $("span").css("display", "inline").fadeOut("slow"); 
    });

Upvotes: 0

Samir Talwar
Samir Talwar

Reputation: 14330

You can trigger an event on scroll:

$(window).scroll(function() {
    if ($(this).scrollTop() > 0) {
        topDiv.show();
    } else {
        topDiv.hide();
    }
});

Upvotes: 5

Related Questions