Avoid window jump to top when clicking #-links

You need to add preventDefault() to your click handler. This will stop the browser executing it’s own link handler, and will only run the code you specify.

Example:

$("#myID").click(function(e) {
    e.preventDefault();
    // Do your stuff
});

Leave a Comment