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

后端 未结 10 1141
走了就别回头了
走了就别回头了 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:44

    if you bind some action on click on you can call preventDefault() to avoid sending user in top of page

    $("a.clickable").live('click',function(){$(this).doSome(); $(this).preventDefault()});
    

提交回复
热议问题