Magento2 JavaScript RequireJS – How to Defaultly Open Content 2 Tab in Magento 2

javascriptjquerymagento2requirejs

I am using accordion for tab open and close.
How to open default "content 2" tab?

<div class="block filter" id="layered-filter-block" data-mage-init='{"collapsible":{"openedState": "active", "collapsible": true, "active": true, "collateral": { "openedState": "filter-active", "element": "body" } }}'>                              
    <div class="block-content filter-content">                  
        <div class="filter-options" id="narrow-by-list" data-role="content" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": true, "multipleCollapsible": true}}'>
            <div data-role="collapsible" class="filter-options-item" >
                <div data-role="title" class="filter-options-title">title 1</div>
                <div data-role="content" class="filter-options-content">content 1</div>
            </div>  
            <div data-role="collapsible" class="filter-options-item" >
                <div data-role="title" class="filter-options-title">title 2</div>
                <div data-role="content" class="filter-options-content">content 2</div>
            </div>
            <div data-role="collapsible" class="filter-options-item" >
                <div data-role="title" class="filter-options-title">title 3</div>
                <div data-role="content" class="filter-options-content">content 3</div>
            </div>                  
        </div>                      
    </div>
</div>

Best Answer

Magento 2 docs - Accordion

Set active to the tab you'd like to be open by default instead of true. For example:

$("#element").accordion({ active: "0 1"});
$("#element").accordion({ active: [0,1]});

So in your case it should be:

data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": "2", "multipleCollapsible": true}}'

Replacing 2 with the tab you require to be open.

TLDR

Change "active": true, to "active": 1 where 1 is the tab you wish to be open by default.