Make all tabs collapsed in accordion by default within jquery

I’m using an accordion widget in my WP based website footer and I want to make all tabs closed by default (now the first tab is always shown). Here is a sample of code of this widget (I copied it deirectly from the inspector panel):

<section id="presscore-accordion-widget-9" class="widget widget_presscore-accordion-widget wf-cell wf-1-3">
<div class="widget-title">Formationen der otmarmusik</div>
<div class="st-accordion">
<ul>
<li><a class="text-primary" href="#"><span>Title</span></a><div class="st-content"><p>Text</p>
</div>
</li>
<li><a class="text-primary" href="#"><span>Title</span></a><div class="st-content"><p>Text</p>
</div>
</li>
<li><a class="text-primary" href="#"><span>Title</span></a><div class="st-content"><p>Text</p>
</div>
</li>
</ul>
</div>
</section>

I tried to use some custom JavaScript

$('.accordion').accordion({
    active: false,
    collapsible: true            
});

but it doesn’t help and it occurs a new error:

Uncaught TypeError: $ is not a function

So I have 2 issues:

  • First. How to make all tabs collapsed by default.
  • Second. How to use custom JavaScript function without any errors in
    WP.

Thank you for your help.

Read more here: Make all tabs collapsed in accordion by default within jquery

Leave a Reply

Your email address will not be published. Required fields are marked *