kandysingh
kandysingh

Reputation: 179

Want to hide a tab (data-tab) using jQuery?

<ul class="total"> 
    <li data-tab="general"><i class="final"></i></li> 
    <li data-tab="normal"><i class="small"></i></li>  
</ul>

I have done this to hide only general tab. But it will hide the complete data. What is the best solution to do this ?

$(document).ready(function(){
    var tabs = $("li[data-tab='general']");
    tabs.hide();

Upvotes: 1

Views: 4653

Answers (2)

turson
turson

Reputation: 421

Check li has data-tab=general and then hide

$(document).ready(function () {

    var tabs = $("ul#total li");
    $.each(tabs, function () {
        if ($(this).attr('data-tab') == 'general') {
            $(this).hide();
        }
    });

});

Upvotes: 0

Roman Bekkiev
Roman Bekkiev

Reputation: 3118

It is not clear what you really want to get. But if you wanna get any element with data-tab attribute specified use this selector:

$("li[data-tab]");

Upvotes: 3

Related Questions