page orientation with a dropdown menu

-2

I have on a page of my site a dropdown menu with a list of rock bands. When you click on the menu it "drops" down showing the list, clicking on some band in that list it closes that menu dropdown and brings in a div down the information of the selected band. But when you select a band from the bottom of that menu it does not go up the page for the beginning of the band's information, it gets in the middle of the information.

I'd like to know how to get him to go to the top of this information. Oh, I already tried anchoring in menu and info , but it does not go to the anchor part. If someone wants to take a look at menu in action the page is this: link . Could someone help me?

    
asked by anonymous 26.09.2016 / 14:26

1 answer

0

After a search I found the code responsible for the event.

$(document).ready(function(){
    $("#banda a").click(function( e ){
    e.preventDefault();
    var href = $( this ).attr('href');
    $("#div1").load( href +" #div1");
    });
});

First, this code does not have to be within $(document).ready because it does not run immediately.

You want to return to the beginning of the div after .load , so you should add an anonymous function as a parameter in your event:

$("#div1").load( href +" #div1", function(){
    $(this).animate({ scrollTop: 0 }, "fast");
});

This will force the scroll to the beginning of the div using a quick animation.

    
26.09.2016 / 14:36