[Fixed]-Django jump directly to div

0👍

✅

Eventually managed to get this working by the following means. Firstly, by adding another ID parameter:

<a data-toggle="collapse" data-parent="#accordion" href="#faq1-2" id="faq1_2">

That fixed moving the relevant section to the top, but it then needed some javascript to move the section viewed out from under a banner and also to expand the view:

$(window).load(function () {
        if (window.location.hash) {
            var faq = window.location.href.split('#')[1];
            var tbody = faq.replace(/_/,'-');
            $('#' + tbody).addClass("in");
            window.scrollBy(0,-160);
        }

    });

1👍

I can’t see all of your html, but if your page doesn’t scroll (as in, there’s not enough info on the page to need a scroll bar) then the page is not going to jump, because there is nowhere to jump to.

You shouldn’t need jQuery to accomplish this. Your code is right to have <a href="#faq9-1"></a> and the div being <div id="faq9-1">

Leave a comment