Adyyda
Adyyda

Reputation: 335

Disable a specific tab

Please take a look at http://jsfiddle.net/Adyyda/uyxrqhex/

I need to disable the second tab and i have no clue how to do it.

For jquery-ui we can use disabled: [1] but i do not know if that will work with my demo and if will work, how to do it. Thanks for the help

Upvotes: 0

Views: 1153

Answers (1)

cdwyer
cdwyer

Reputation: 697

I made a couple of changes. Added a "disabled" class to tab 2's <li> and changed your jQuery to use .on. It also now filters out the .current and .disabled classes.

HTML for List

<ul class="tabs">
    <li class="current">Tab 1</li>
    <li class="disabled">Tab 2</li>
    <li>Tab 3</li>
    <li>Tab 4</li>
</ul>

jQuery

$('ul.tabs').on('click', 'li:not(.current, .disabled)', function() {
 $(this).addClass('current').siblings().removeClass('current')
   .parents('div.section').find('div.box').eq($(this).index()).fadeIn(150).siblings('div.box').hide();

})

Link here: jsFiddle

Upvotes: 2

Related Questions