开发者

.animate jquery moves to the top of the page (filterable image gallery)

开发者 https://www.devze.com 2023-02-10 07:59 出处:网络
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 cur

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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消