I need a <a href="#" class="link-one">Link</a> outside nav-tabs to activate a tab-panel/tab-content using Bootstrap 5.
Basically, how can I simplify this?
// show relevant Bootstrap tab from a outside link click
$('.link-one').on('click', function(){
$('#tab-one-pane').addClass('show active');
$('#tab-two-pane').removeClass('show active');
$('#tab-two').removeClass('active');
$('#tab-one').addClass('active');
});
$('.link-two').on('click', function(){
$('#tab-two-pane').addClass('show active');
$('#tab-one-pane').removeClass('show active');
$('#tab-one').removeClass('active');
$('#tab-two').addClass('active');
});
Thank you in advance.
Add a class called
linkto youranchortags making thedata-targetattribute your unique IDsHTML:
JS:
This will solve the repeating code.