show dynamically added navlinks when added in bootstrap navbar

后端 未结 1 1578
走了就别回头了
走了就别回头了 2020-12-06 23:13

I am new to Bootstrap, and can\'t seem to figure this out, i have navbar being used as javascript tab functionality of Bootstrap, which can have dynamically added and remove

相关标签:
1条回答
  • 2020-12-06 23:53

    It doesn't look like you're using the standard Bootstrap nav/nav-tabs markup. If I were you I would simplify adding new tabs and tab content like this...

    Have a single function that creates the new tab, tab content and then makes it active. You can use the tab('show') method to activate the newly created tab:

    $('#btnAdd').click(function (e) {
        var nextTab = $('#tabs li').size()+1;
    
        // create the tab
        $('<li><a href="#tab'+nextTab+'" data-toggle="tab">Tab '+nextTab+'</a></li>').appendTo('#tabs');
    
        // create the tab content
        $('<div class="tab-pane" id="tab'+nextTab+'">tab' +nextTab+' content</div>').appendTo('.tab-content');
    
        // make the new tab active
        $('#tabs a:last').tab('show');
    });
    

    Dynamic Bootstrap Tabs Demo

    Then you just need to customize it a little for your images.

    0 讨论(0)
提交回复
热议问题