开发者

How to get screen not to jump back to up when clicking div to open

i got page with multiple open/hide divs and the problem here is that everytime i try to click one to open or hide the screen jumps at the top of the page..

Anyone idea how t开发者_JAVA技巧o fix this? Javascript is used to hide divs.

Thanks!


$(function() {
$('a.hide').click(function() {
    $(this).closest('.hideable').find('.hide-container').toggle();
});

$('a#hide-all').click(function() {
    $('.hide-container').hide();
});

 $('.hide-container').hide(); });


It sounds like you are using href="#", don't do that, build on things that work instead.


If you’re using an A tag to open close the DIV’s, it means that in Javascript you’ll need to disable the default action for the A tag.

In jquery for example:

$('a').click(function(e) {
    e.preventDefault();
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜