Alternative to when the anchor tag only triggers a jQuery action without redirecting the user?

后端 未结 10 1156
走了就别回头了
走了就别回头了 2021-02-09 15:57

I have numerous anchor tags on my page that only trigger jQuery actions on the same page.

The don\'t redirect the user to another location, which is the normal expected

10条回答
  •  离开以前
    2021-02-09 16:41

    I prefer to use:

    foo
    

    unless it is actually an ajax call to load a partial template in which case I use something like this:

    foo
    

    By returning false in the onclick event, you make sure the site is not reloaded, but it can still be used for opening the url in a new page.

提交回复
热议问题