michaelmueller4321 Posted April 7, 2020 Share Posted April 7, 2020 Hello! I use this Accordion: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_symbol How to open accordion section from an external link, like: https://www.test.com/test.html#section1 Thank you very much. Michael Link to comment Share on other sites More sharing options...
ishan_shah Posted April 20, 2020 Share Posted April 20, 2020 (edited) When the page loads your ready function will run, this should open the accordion section the URI's hash refers to: jQuery(document).ready(function() { // get the #section from the URL var hash = window.location.hash; // open accordion jQuery(hash).slideDown(300).addClass('open'); // set title to active jQuery(hash).prev('.accordion-section-title').addClass('active'); /* ... the rest of your code here */ }); you might get a slight performance boost if you don't get the jQuery object twice, you can chain these like this: jQuery(hash).slideDown(300).addClass('open') .prev('.accordion-section-title').addClass('active'); Edited April 20, 2020 by ishan_shah Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now