Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active October 27, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/58a1c848f25f053748a7acc1e36ac86e to your computer and use it in GitHub Desktop.
Save wplit/58a1c848f25f053748a7acc1e36ac86e to your computer and use it in GitHub Desktop.
link to accordion item inside Pro Accordion component with hashlink from another page
jQuery(document).ready(function($) {
// open the accordion if hash link
var hash = window.location.hash;
if (hash) {
var element = $(hash);
setTimeout(function() {
// Only if element is found and is part of a Pro Accordion item
if (element.length && element.parent('.oxy-pro-accordion_item').length) {
// Open up the accordion
element.trigger('click');
// scroll to the element.
$([document.documentElement, document.body]).animate({
scrollTop: $(hash).offset().top - 100
}, 1000);
}
}, 1000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment