Anchor tag with onclick and href='#' scrolls to top

后端 未结 2 1593
孤街浪徒
孤街浪徒 2021-01-17 11:57

I have an anchor tag

Register

If you don\'t have a href in you anchor, it can screw

2条回答
  •  滥情空心
    2021-01-17 12:46

    You can add a return false;, like this:

    Register
    

    This prevents the default action of the anchor, which is to go to the hash, causing the scroll.

提交回复
热议问题