Search code examples
jqueryjquery-uijquery-ui-tabs

Correct way to link href to jQuery UI tab


What is the correct way to link a href to a jQuery UI tab?

I've tried this so far and it doesn't seem to be working:

    $("#search").tabs();

    $('#2a').click(function () {
        $("#search").tabs('select', 1);
        return false;
    });

    $('#2b').click(function () {
        $("#search").tabs('select', 2);
        return false;
    });

Here is my code: http://jsfiddle.net/bWHt6/


Solution

  • That's how you do it, except that indexes start from zero. The first tab is 0, the second is 1 and so on.

    $('#2a').click(function () {
        $("#search").tabs('select', 0);
        return false;
    });
    
    $('#2b').click(function () {
        $("#search").tabs('select', 1);
        return false;
    });
    

    Demo