I have an accordion with 4 tabs on my page and they’re linked. It’s visible in mobile view and because of the length the view needs to slide to the top of the tab when it’s opened. I found this script from one of the old support threads. It appears to work on the first accordion tab on my page but then breaks as I open more tabs. Please help.
jQuery(document).ready(function($) { $('.x-accordion-toggle').click(function() {
var cur = $(this).offset().top;
var navbar = $('.x-navbar').outerHeight() + $('#wpadminbar').outerHeight();
console.log(cur);
setTimeout(function() {
$('html, body').animate({
scrollTop: cur - navbar
}, 700, 'swing');
}, 300);
});
});