0

I have a link like this: <a href="mywebsite/testing/#collapse416">Testing</a></li> Which opens an accordion on a page. It targets the div of the collapse of the bootstrap accordion. However when it opens, it's not opening at the top of the div. I realized it's because my banner on top is fixed and when it opens the target link, its not accounting for the offset I added to the body.

So how would I add an offset padding top to the target link. So that it offsets the fixed banner. This is the code im using so far to target and open the accordion:

<script type="text/javascript">
(function( $ ) {
    $(document).ready(function() {
        var anchor = window.location.hash.replace("#", "");
        $(".collapse").collapse('hide');
        $("#" + anchor).collapse('show');
    });
})( jQuery );
</script>
  • Make jsfiddle or spiner and give all of code html and css and js. It will be help you to get your answer fast. – MD Ashik Nov 23 '16 at 19:20

1 Answers1

0

Did you try to add a class to the element?

ref How do I add a class to a given element?

Community
  • 1
  • 1
NMenam
  • 114
  • 2
  • 13