views:

52

answers:

1

When #my-text-link is clicked, i need to select tab 5 and when tab 5 is selected i need to hide #my-text-link. hope this makes sense, heres the code, and also what I have done so far, please feel free to show me a better way. Thanks in advance

    var $tabs = $('.tabbed').tabs(); // first tab selected
        $('#my-text-link').click(function() { // bind click event to link
            $tabs.tabs('select', 4); // switch to third tab
            $('#my-text-link').hide();
            return false;
        });


<a href="#" id="my-text-link"></a>

<ul>
<li class="one"><a href="#tabs-1" title="Summary"></a></li>
<li class="two"><a href="#tabs-2" title="Detailed Info"></a></li>
<li class="three"><a href="#tabs-3" title="Images"></a></li>
<li class="four"><a href="#tabs-4" title="Reviews"></a></li>
<li class="five"><a href="#tabs-5" title="Dates &amp; Prices"></a></li>
</ul>

<div id="tabs-1"></div>
<div id="tabs-2"></div>
<div id="tabs-3"></div>
<div id="tabs-4"></div>
<div id="tabs-5"></div>
A: 

As far as I can see from your code, you've already managed to open a tab when the link is clicked. Here's how you hide the link when user opens the tab:

$(".tabbed").tabs({
    select: function(event, ui) {
        var tabId = ui.panel.id.substring(5);
        if (tabId == 5) {
            $('#my-text-link').hide();
        }
    };
})

Hope this helps

Juriy