Skip to content Skip to sidebar Skip to footer

Removing Id Attribute To Link From My Url

For some reason unknown to me the id attribute to link to a section of my webpage gets stuck in the url after clicking on it. To see a live example of what I mean you can please v

Solution 1:

#1: That's how it is supposed to work #2: As noted in the other answer that is called hashes, and you would use jquery to fix it. I like this little script it removes the hashes, and has a nice scroll animation instead of a jump: JQuery:

jQuery(document).ready(function($) {
    $(".scroll").click(function(event) {
       event.preventDefault();
       $('html,body').animate( { scrollTop:$(this.hash).offset().top } , 1000);
    });
});

HTML:

<ahref="#second"class="scroll" ><buttonclass="btn">Click Here To Pre-Order</button></a>

Demo: http://jsfiddle.net/ImagineStudios/c604vbrn/11/

Solution 2:

Try using this snippet.

<buttonclass="btn"><ahref="#bottom">Click Here To Pre-Order</a></button><aid="bottom"></a>

Solution 3:

That's how hashes work. If you reload the page browser tries to find an element that has the current hash as it's id and focuses on it. If that's not what you want, you should prevent the default action of the click event, then the document's hash won't be updated, but then you should select the target element using JavaScript and change the scroll position of the window according to top offset of the target element.

And your markup is invalid. Where is the opening button tag and why a button element in an a element?

Post a Comment for "Removing Id Attribute To Link From My Url"