-4

i want a simple JS code to detect Scrolling of HTML page.

Check this page : http://conf.iranwebfestival.com/

As you scroll the page, the top menu elements, get CSS borders .

I need somthing to do that .

Kawinesh S K
  • 3,148
  • 1
  • 16
  • 29

4 Answers4

1

That page doen't render properly on my device.. But to detect scrolling with jQuery, I'd check the value of $(window).scrollTop(), and if it was bigger than 0, it would mean the user had scrolled. Something like this:

$(window).scroll(function() // when user scrolls
{
    if($(window).scrollTop() > 0)
        // scrollbar is not at the top
    else
        // scrollbar is at the top
}
1

Although it's very much your responsibility to prove you have at least tried, googled it, whatever, and you have not done this, this answer is simple enough in jQuery

$(window).scroll(function(){
  //Whatever you want to do
});
ggdx
  • 3,024
  • 4
  • 32
  • 48
1

You could use jQuery Waypoints. Or if you're using Bootstrap look into Scrollspy.

You should put some effort into implementing it. A simple search would have got you what you wanted.

kartikluke
  • 2,375
  • 1
  • 19
  • 32
1

jQuery has a function scrollTop to find how much screen was scrolled down. Here is base of using

$(window).scroll(function(){
var ScrolledDown = $(window).scrollTop();
});

and here is a example how to use jQuery's function scrollTop - and avoid scrolling if you achieved bottom of page.

Switch div from fixed to absolute at bottom of browser (see my answer)

Community
  • 1
  • 1
Václav
  • 527
  • 7
  • 28
  • Thanks, @Sparky, for next advice - but at this time I only would like to know explanation of reverse of 200 points of reputation I got by upvotes yesterday. What happened? – Václav Feb 23 '14 at 07:03
  • A quick [glance at your profile screen](http://stackoverflow.com/users/3263387/vaclav?tab=reputation) shows that you were flagged for "serial up-voting". You'll have to go over to meta stackoverflow and ask the moderators about this. – Sparky Feb 23 '14 at 17:30