Accordion scroll to the correct position

Hello,
I used this code on another page to always get to the right place with an accordion:

jQuery (document) .ready (function ($) {
$ (’. x-accordion-toggle’). unbind (). on (‘click’, function () {
var $ this = $ (this);
setTimeout (function () {
$ (‘html, body’). animate ({
scrollTop: $ this.offset (). top -180
}, 300);
}, 500);
});
});

Classic accordion is set up on this side.

This code does not work on another website. Here I am using accordion.

How do I manage that the accordion always goes to the right place (header).

thank you for your help
Thomas

Hi Thomas,
Thanks for reaching out.

The selector element is not present in the second website, where your code is not working. The class x-accordion-toggle is not there to trigger the event. Instead of the x-accordion-toggle class, you can use the x-acc-header.

Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle. We do not provide support for custom codes that means we can’t fix it in case it conflicts with something in your site nor will we enhance it.
Please remember that we do not provide support for custom codes that means we can’t fix it in case it conflicts with something in your site nor will we enhance it.

Thanks

Thank you very much. Its perfect now.

Thomas

Hi Thomas,

You’re welcome and it’s our pleasure to help you. If you have any other concerns, feel free to reach us.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.