Disable bootstrap tab clicks

后端 未结 9 1182
走了就别回头了
走了就别回头了 2021-01-14 15:24

I am using bootsrap tabs for a registration form , I changed navigation of tabs using onclick event of next and previous button . But still that tabs click works and being

9条回答
  •  逝去的感伤
    2021-01-14 15:40

    I have tabs like this in the HTML (using Bootstrap 3.0):

    
    

    Next/Previous buttons

    
     
    

    In my JavaScript file:

     var $tabs = $('#createNotTab li');
    
    
    function showPrev() {
        $tabs.filter('.active').prev('li').removeClass("disabled");
        $tabs.filter('.active').prev('li').find('a[data-toggle]').each(function () {
           $(this).attr("data-toggle", "tab");
        });
    
        $tabs.filter('.active').prev('li').find('a[data-toggle="tab"]').tab('show');
    
        $tabs.filter('.active').next('li').find('a[data-toggle="tab"]').each(function () {
            $(this).attr("data-toggle", "").parent('li').addClass("disabled");        
        })
    }
    
    function showNext() {
        $tabs.filter('.active').next('li').removeClass("disabled");
        $tabs.filter('.active').next('li').find('a[data-toggle]').each(function () {
            $(this).attr("data-toggle", "tab");
        });
    
        $tabs.filter('.active').next('li').find('a[data-toggle="tab"]').tab('show');
    
        $tabs.filter('.active').prev('li').find('a[data-toggle="tab"]').each(function () {
            $(this).attr("data-toggle", "").parent('li').addClass("disabled");;        
        })
    }
    

    If you are having multiple tabs, set class="disabled" and data-toggle="" for all the li items that you want to deactivate.

提交回复
热议问题