javascript - scroll(0,0) working while scrollTo(0,0) not working? -


ehy guys. have strange kind of problem. i've created button scroll page bottom when user clicks it, , works if use scroll(0,0), while if use scrollto(0,0) (which should work in same way guess) doesn't work (the page doesn't scroll, nothing happens). here part of code: function should scroll top after click using scrollto doesn't anything.

<button id="scrollainalto" onclick="scrollinalto();"              style="background-color:transparent;border:none;display:none;"></button> <script>   function scrollinalto() {       window.scrollto(0,0); <-- 1 doesn't work       //window.scroll(0,0); <-- 1 works   } </script> 

the other thing have small script show , hide button scrolls page: here is.

<script>         $(document).ready(function(){            $(window).scroll(function(){              var $temp = $("#scrollainalto").scrolltop();              if (document.body.scrolltop > 50) {                  $("#scrollainalto").show();              } else {                  $("#scrollainalto").hide();              }            });         }); </script> 

why doesn't scrollto work properly?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -