, , , data-accordion-target.
HTML
<div id="tabs">
<ul>
<li><a href="#tab1">tab1</a></li>
<li><a href="#tab2">tab2</a></li>
<li><a href="#tab3">tab3</a></li>
</ul>
<div id="tab1">
<h2>Tab1 Header</h2>
<div class="accordion">
<h3>Tab1 Accordion 1</h3>
<div>
<p><a href="#tab2" data-accordion-target="0">This should take you to tab2 accordion 1</a></p>
</div>
<h3>Tab1 Accordion 2</h3>
<div>
<p><a href="#tab3" data-accordion-target="1">This should take you to tab3 accordion 2</a></p>
</div>
</div>
</div>
<div id="tab2">
<h2>Tab2 Header</h2>
<div class="accordion">
<h3>Tab2 Accordion 1</h3>
<div>
<p><a href="#tab1" data-accordion-target="0">This should take you to tab1 accordion 1</a></p>
</div>
<h3>Tab2 Accordion 2</h3>
<div>
<p><a href="#tab3" data-accordion-target="0">This should take you to tab3 accordion 1</a></p>
</div>
</div>
</div>
<div id="tab3">
<h2>Tab3 Header</h2>
<div class="accordion">
<h3>Tab3 Accordion 1</h3>
<div>
<p><a href="#tab1" data-accordion-target="1">This should take you to tab1 accordion 2</a></p>
</div>
<h3>Tab3 Accordion 2</h3>
<div>
<p><a href="#tab2" data-accordion-target="1">This should take you to tab2 accordion 2</a></p>
</div>
</div>
</div>
</div>
jQuery trigger, , , , .
$(function() {
$(document).ready(function(){
var getHash = function(key){
var parts = window.location.hash.substr(1).split(/\|/);
var _key = parseInt(key) || 0;
return _key < parts.length ? parts[_key] : false;
};
var setHash = function(key, value){
var parts = window.location.hash.substr(1).split(/\|/);
var _key = parseInt(key) || 0;
parts[_key] = value;
window.location.hash = '#' + parts.join('|');
};
$(".accordion").accordion({
heightStyle: "content",
collapsible: true,
animated: 'slide',
navigation: true,
activate: function(event, ui) {
if(ui.newHeader.length > 0){
setHash(1, ui.newHeader.parent().children('h3').index(ui.newHeader));
}else{
setHash(1, '');
}
},
active: false
});
$( "#tabs" ).tabs({
collapsible: true,
activate: function(event, ui) {
if(ui.newTab.length > 0){
var tabHash = ui.newTab.parent().children().index(ui.newTab);
if(tabHash == getHash(0)){
ui.newPanel.find('.accordion').accordion('option', 'active', parseInt(getHash(1)));
}else{
setHash(1,'');
}
setHash(0, tabHash);
}else{
window.location.hash = '';
}
},
create: function(event, ui){
if(ui.tab.length > 0){
var tabHash = ui.tab.parent().children().index(ui.tab);
if(tabHash == getHash(0)){
ui.panel.find('.accordion').accordion('option', 'active', parseInt(getHash(1)));
}else{
setHash(1,'');
}
setHash(0, tabHash);
}
},
active: parseInt(getHash(0)) || 0
});
});
var internalLinks = $(".accordion").find("a");
$.each(internalLinks,function(i,v){
$(v).on('click',function(e){
var h3Index = parseInt($(v).attr("data-accordion-target"));
e.preventDefault();
var id = $(v).prop("href").split("#")[1];
$("li").find("a[href=#"+id+"]").trigger("click");
$( "#"+$(v).prop("href").split("#")[1]).find(".accordion").accordion('option','active', h3Index);
});
});
});
http://jsbin.com/qebocevete/edit?html,js,output