One of the links on my website looks like this:
<a href="mywebsite/testing/#collapse416">Testing</a></li>
When clicked, it opens an accordion on a page by targeting the div of the collapse of the bootstrap accordion. However, I noticed that it doesn't open at the top of the div because there is a fixed banner at the top which affects the positioning. It seems that the offset I added to the body is not being considered when the link opens.
I am now wondering how I can add an offset padding top to the target link in order to account for the fixed banner and ensure that it displays correctly. This is the code snippet I'm currently using 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>