开发者

How do I prevent auto scroll to a certain element when I click on that?

开发者 https://www.devze.com 2023-04-06 18:48 出处:网络
I have a page where when I click on a menu item, it will load the content using anchor tag navigation. This means I use # on the address bar to prevent loading the whole page using ajax.

I have a page where when I click on a menu item, it will load the content using anchor tag navigation. This means I use # on the address bar to prevent loading the whole page using ajax.

My problem is that whenever I click on a menu button, before the new content is loaded, the window automatically scrolls to the position of the menu item I clicked.

I know this can be "solved" by window.scrollTo(0,0) but I don't want to see scroll jumping around whenever I load a content.

note: I have no idea where this is happening s开发者_开发技巧o I can't really post my code...


$('.link').click(function(ev){
   //....Ajax stuff
   ev.preventDefault();
});
0

精彩评论

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