Prevent a link to reload page

前端 未结 7 1610
时光取名叫无心
时光取名叫无心 2020-12-10 16:43

I am creating a responsive menu: Codepen Demo

To avoid the page to be reloaded when I click a link I have:

$(\'nav.menu a[href=\"#\"]\').click(functi         


        
相关标签:
7条回答
  • 2020-12-10 17:21

    And an inline option without jQuery:

    <a href="javascript:function f(e){e.preventDefault();}">Link</a>
    

    And don't forget that with this you have already used the "f" name for a function, so don't name other function like this.

    0 讨论(0)
提交回复
热议问题