aintgel
aintgel

Reputation: 658

JQuery - How can I manipulate tabs

How can I manipulate the jquery tab, for example when a submit form is triggered in tab2 then the page selected tab should be the tab2 not the tab1?

Upvotes: 0

Views: 209

Answers (2)

neoascetic
neoascetic

Reputation: 2566

If you use jQuery UI tabs, check their selected option. Docs.

So, in your php code you must set this option on your tabs, like so:

$('#tabs').tabs({ selected: 2}); // 2nd tab will be default selected

or so, after tabs creating (if creation code in separate file, for example):

$('#tabs').tabs('option', 'selected', 2);

Also, you can emulate clicking by tab using:

$('#tabs a[href=#tab_id]').click(); // where `tab_id` is tab content identifier

Upvotes: 1

S.831
S.831

Reputation: 123

if it is just for UI display, just simply trigger the tab click action programmatically like this $("tab2Selector").click();

Upvotes: 0

Related Questions