i'm trying to create a button or link that opens a specific accordion tab, here is my accordion structure:
<div class="tabs">
<div class="tabs-header">
<div class="border"></div>
<ul>
<li class="active"><a href="#tab-1" tab-id="1">Home</a></li>
LINK HERE to open Tab 2
LINK HERE to open Tab 3
<li><a href="#tab-2" tab-id="2">Symptom Checker</a></li>
<li><a href="#tab-3" tab-id="3">Locator</a></li>
</ul>
</div>
<div class="tabs-content">
<div tab-id="1" class="tab active"></div>
<div tab-id="2" class="tab"></div>
<div tab-id="3" class="tab"></div>
</div>
I'm guessing there will be a onclick event I can apply to a button? i've tried:
<a href="#tab-2" tab-id="2">Symptom Checker </a>
but nothing happens other than updating the URL
you can use
$('your_button').on('click',function(){ $( "#accordion" ).accordion( "option", "active", 1 ); });
for tab2 and
$('your_button').on('click',$( "#accordion" ).accordion( "option", "active", 2 );})
for tab3
or you can use onclick property
<a onclick="$( '#accordion' ).accordion( 'option', 'active', 1 )">Click here for tab2</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.