How to scroll to an element in jQuery?

后端 未结 9 1708
无人及你
无人及你 2020-11-30 19:23

I have done the following code in JavaScript to put focus on the particular element (branch1 is a element),

document.location.href=\"#branch1\";
         


        
9条回答
  •  Happy的楠姐
    2020-11-30 19:56

    For my problem this code worked, I had to navigate to an anchor tag on page load :

    $(window).scrollTop($('a#captchaAnchor').position().top);
    

    For that matter you can use this on any element, not just an anchor tag.

提交回复
热议问题