Reputation: 7269
I know there are some threads with same question, but mine is a bit different.
I know how to activate tab on element click. There are many answers about it. For example, this one.
I need to activate tab not on click, but on page load depending on GET query. I am getting param from GET query and then want to activate tab depending on this param.
<?
$type = $_GET['type'] ? $_GET['type'] : '0';
?>
<script>
$(function() {
var type = <?=$type; ?>;
if(type == 1)
{
// activate 1 tab
}
else-if(type == 2)
{
// activate 2 tab
}
else
{
// activate 2 tab
}
</script>
It is just an example.
So the question is: how to use tabs
method without selector. ~ like there:
$.tabs({
active: type
});
(This one not working)
Upvotes: 0
Views: 880
Reputation: 327
Try this one:
$('#your_tab_id').tabs({ selected: <?php echo $type; ?> });
Upvotes: 0
Reputation: 3200
You can select the tabs simply triggering the click action on the desidered tab:
$("#tabId").trigger("click");
Upvotes: 2