JavaScript show/hide tab

后端 未结 3 1387
悲&欢浪女
悲&欢浪女 2021-01-20 07:08

What i want is hide all content first, then click one tab, the corresponding content shows (the tab becomes \'active\'), where click it again it will disappear. some of the

3条回答
  •  粉色の甜心
    2021-01-20 07:35

    Change the click function to:

    $('#nav ul li a').click(function(){ 
        var currentTab = $(this).attr('href');  
        $('#nav div').not(currentTab).hide();
        $('#nav ul li').removeClass('active');
        $(this).parent().toggleClass('active');     
        if (currentTab.indexOf("mailto:") === -1)
        {
            $(currentTab).toggle();
        }
    });
    

    Working example

提交回复
热议问题