0

Thanks to Christina for giving the answer that worked for me (the second option that requires document ready): Twitter Bootstrap3 - Make An Accordion Expand On A Different Page When A Link Is Clicked

My accordion is many and has lots of content so I need it to scroll to the top of the opened accordion tab. I've tried this suggestion but doesn't work: Navigate to Bootstrap Accordion from Another Page

My current script:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

 <script>
 $(document).ready(function() {
 var anchor = window.location.hash.replace("#", "");
 $(".collapse").collapse('hide');
 $("#" + anchor).collapse('show');
 });
 </script>

Also, I'm using BS5, not sure if my script above requires updating or if there's a way to change this to Vanilla JS. I'm still learning JS so couldn't work it out myself for the time being.

jand1
  • 9
  • 3

0 Answers0