skip to Main Content

I need to hide anchor on my url.

<a href="#book">Book</a>

This anchor is attached on jquery smooth scroll, when i click my url become:

www.test.it/#book

I don’t want #book on my url.

is possibile?

And is possibile hide from another page?

example: www.test.it/#book to www.test.it

I see this thing on boostrap modal.

Can see here, on my site: http://www.alessandrapinto.it/

2

Answers


  1. You will need to add this:

    e.preventDefault();
    
    $('#myLink').click(function(e) {
        e.preventDefault();
        //do other stuff when a click happens
    });
    

    To the end of your jQuery function.
    and then you will not see the #something in the URL.

    For example, clicked anchors will not take the browser to a new URL. We can use event.isDefaultPrevented() to determine if this method has been called by an event handler that was triggered by this event.

    Login or Signup to reply.
  2. if there is # in url it will update URL by default. You need to do this with jquery if you don’t want to add # in URL. Add Id your anchor I am taking this as id=”name” then add class to your div till where you want to scroll your page I am taking this like class=”name”

    $("#name").click(function(e) {
    e.preventDefault();
        $('html, body').animate({
            scrollTop: $(".name").offset().top
        }, 2000);
    });
    

    DEMO

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search