Matt Elhotiby
Matt Elhotiby

Reputation: 44086

JQuery page jumping to the top of the page

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();
            }
        });
    });

Upvotes: 3

Views: 2123

Answers (1)

Ryan Kinal
Ryan Kinal

Reputation: 17732

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;
        });
    });

Upvotes: 10

Related Questions