简体   繁体   中英

Jquery : Function to autoscroll the page on load

I need a jquery function that will scroll the page (from where the user currently is) by 100 pixels. Please note, this function does not scroll from the top, it scrolls from the current position. so far i have :

 <script type="text/javascript"> 
  $(document).ready(function() {
     $(window).scrollTop($(window).scrollTop()+100);
  });
 </script>

It doesn't do anything.

Thanks to @HirstoYankov for partly helping.

Below is the code that fixed it:

<script type="text/javascript">
   $(window).load(function () {
  $(window).scrollTop($(window).scrollTop()+1);
    });
</script>

Its important to use $(window).load and not $(document).ready

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM