remove the #anchor-id when scrolling

前端 未结 2 1509
一向
一向 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

    0 讨论(0)
  • 2021-01-24 12:31

    The example explicitly adds the tag to the url:

    // Set hash in URL after animation successful
    location.hash = target;
    

    You should be able to remove/comment this line.

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