Timothy's Dev Stuff

A collection of code snippets and other developer things.

Make Elementor Accordion Default to Collapsed

By default, Elementor’s accordion has the first content section expanded. This snippet prevents that – so the accordion is collapsed by default.

jQuery(document).ready(function ($) {
    var delay = 100; setTimeout(function () {
        $('.elementor-tab-title').removeClass('elementor-active');
        $('.elementor-tab-content').css('display', 'none');
    }, delay);
});
I have found it useful to use the HTML block in Elementor and paste the code there unless a more elegant solution is needed. The block can be added just after the accordion and the JavaScript can be wrapped in a <script> tag. This will ensure that the code only executes on the page where it is needed.