samedi 2 juillet 2016

Prevent href="#" loosing focus (scrolling up to top of the page) [duplicate]

This question already has an answer here:

I was wondering if its possible to prevent the empty href link to scroll up on top of the page when that link is clicked.

For instance I have:

<a href="#">Hello world</a>

If the "Hello world" link is lets say on middle of the page and I click it (if its in this form like i stated above), when I click this link, my url would look like this:

myurl.com/#

However, what happens is that each time this link is clicked as empty href tag, my page scrolls up to top, and I don't want that to happen, it's very annoying and I wanna remove that. Is there any way for me to do that via JavaScript or jQuery?

Aucun commentaire:

Enregistrer un commentaire