문제

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)

도움이 되었습니까?

해결책

You can select the tabs simply triggering the click action on the desidered tab:

$("#tabId").trigger("click");

다른 팁

Try this one:

$('#your_tab_id').tabs({ selected: <?php echo $type; ?> });
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top