最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery page jumping to the top of the page - Stack Overflow

programmeradmin0浏览0评论

I am using this Jquery and it works great The problem is when i click on the button the page jumps all the way to the top. I am using Miva if that makes a difference

$(document).ready(function(){
        $('.drop').click(function(){
            var $next = $(this).parent().next('li.drop_down');
            if($next.is(':visible')) {
                $next.slideUp();
            } else {
                $next.slideDown();
            }
        });
    });

I am using this Jquery and it works great The problem is when i click on the button the page jumps all the way to the top. I am using Miva if that makes a difference

$(document).ready(function(){
        $('.drop').click(function(){
            var $next = $(this).parent().next('li.drop_down');
            if($next.is(':visible')) {
                $next.slideUp();
            } else {
                $next.slideDown();
            }
        });
    });
Share Improve this question edited Jul 12, 2010 at 17:56 SLaks 889k181 gold badges1.9k silver badges2k bronze badges asked Jul 12, 2010 at 17:55 Matt ElhotibyMatt Elhotiby 44.1k91 gold badges224 silver badges328 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 10

Try adding "return false" to the end of your click() function.

Edit: (adding code example)

    $(document).ready(function(){
        $('.drop').click(function(){
            var $next = $(this).parent().next('li.drop_down');
            if($next.is(':visible')) {
                $next.slideUp();
            } else {
                $next.slideDown();
            }

            return false;
        });
    });
发布评论

评论列表(0)

  1. 暂无评论