When my product page loads the first tab is active:
How do I get the 2nd tab to be active on page load, so it looks like this?
You will need to create three files:
var config = {
map: {
'*': {
opentab: 'js/opentab'
}
}
};
Change name to the tab name you want to open on page load
define(['jquery'], function($){
"use strict";
return function opentab()
{
$(document).ajaxComplete(function() {
$('#tab-label-name-title').click();
});
}
});
<script type="text/javascript">
require(['jquery', 'opentab'], function($, opentab) {
opentab();
});
</script>
The other answer takes a very long time to act.
I have found this way works better:
require(["jquery",'jquery/ui','tabs'], function($){
$(function() {
var tabIndex = $('.product.data.items [data-role="content"]').index($('#tab-name'));
$('#tab-label-tab-name').addClass("active");
$('.product.data.items').tabs({
active: tabIndex
});
});
});