I am trying to integrate someones code in my website which is basically a filterable image gallery...but when I click on any link to filter my gallery, my page moves to the top again and loses its current position... Here is the online link to 开发者_如何学编程check the problem.
Please check this link and send me the correct code
This occurs because the link's href is set to #
which moves you to the top of the page.
In the click
handler for those links call preventDefault()
:
$(".myclass").click(function(event){
event.preventDefault();
});
This will prevent the default action, #
, from being executed.
Right at the bottom of your Click trigger for the 'a', add return:false; and it will prevent the browser from jumping to the top :)
精彩评论