jQuery cross-browser “scroll to top”, with animation

前端 未结 8 923
难免孤独
难免孤独 2020-12-09 09:32

Right now I\'m using this:

$(\'#go-to-top\').each(function(){
  $(this).click(function(){ 
    $(\'html\').animate({ scrollTop: 0 }, \'slow\'); return true;          


        
8条回答
  •  独厮守ぢ
    2020-12-09 09:41

    Hm... strange, with jsFiddle I can get it to work fine in Opera (ver 11.01), but in Chrome it just jumps up to the top and doesn't animate it like you want to.

    You can se the jsFiddle here if you want to: http://jsfiddle.net/H7RFU/

    I hope that helps a bit, though it's not really an answer.

    If what I have made isn't what your html etc looks like, please update it and add it.

    Best regards,

    Christian

    Caveat: I haven't used the save function of jsFiddle before so I dunno for how long it it saved.

提交回复
热议问题