remove the #anchor-id when scrolling

前端 未结 2 1511
一向
一向 2021-01-24 11:58

I\'m using this jquery http://css-tricks.com/examples/SmoothPageScroll/ to create a smooth page scroll, however each time I click a scrollable element, the anchor ID appears on

2条回答
  •  借酒劲吻你
    2021-01-24 12:25

    To not show hash ( a browser default behavior), return false from click handler.

    $('a').click(function(){
      // run code
      return false;
    })
    

    or

    $('a').click(function(event){
      event.preventDefault()
      // run code
    
    })
    

    These also prevent browser from loading a url from href, among other things they prevent

提交回复
热议问题