user6708151
user6708151

Reputation: 69

How to change tabs programmatically?

Im using http://www.menucool.com/tabbed-content to make tabs. Is there any way to change tabs by jquery/javascript ? i have tried $("tab1").click();

Created a fiddle for this- https://jsfiddle.net/6e3y9663/1/

Upvotes: 0

Views: 429

Answers (1)

madalinivascu
madalinivascu

Reputation: 32354

Play with the selected class

$('.tabs').find('li.selected').removeClass('selected');//reset the tab buttons
$('#desiredTab').parent().addClass('selected');//or $('li a[href="#tab1"]').parent().addClass('selected'); - select the desired tab header
id = $('#desiredTab').attr('href');
$(id).siblings().hide();//reset the tab content
$(id).show();//$('#tab1').show();  -show the desired tab content

demo:https://jsfiddle.net/6e3y9663/5/

Upvotes: 1

Related Questions