treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Remove # from end of URL

  • Howdy!

    Curious if anyone can suggest a method for removing the hashtag at the end of a URL. In my case the hashtag is visible after I click a link (activating a jQuery .slideToggle) with the following code:

    <a href="#">Link</a>

    The end result is this:

    website.com/#

    (FYI the hashtag never leaves the url)
  • You could always change it to a < span> and just give it some CSS to make the pointer (hand) show up.
  • changing it to a span means that users can't tab to it
    <a href="#" onclick="return false;">Link</a>

    If you are already using a JavaScript eventHandler for this anchor add the return false to the end of the function instead
    Or if you are using jQuery use e.preventDefault();