twitter bootstrap 3 setting active tab in js not working

前端 未结 2 1682
野的像风
野的像风 2020-12-31 02:08

Yeah, so this has been asked about 1000 times, but I tried the answers and none seem to be working for me.

Here are my tabs:

相关标签:
2条回答
  • 2020-12-31 03:10

    You have : in your selector, Change it to

     $('#tab a[href="#security"]').tab('show');
    

    instead of

     $('#tab a:[href="#security"]').tab('show'); 
    
    0 讨论(0)
  • 2020-12-31 03:15

    The first problem is here:

    $('#tab a:first').tab('show')
    

    #tab makes reference to an id="tab", and you don't have one. Replace #tab with .nav-tabs or add an ID to your ul:

    $('.nav-tabs a:first').tab('show')
    

    Your second problem is that you forgot to remove the : next to the a:

    $('.nav-tabs a:[href="#security"]').tab('show')
    

    It should be:

    $('.nav-tabs a[href="#security"]').tab('show')
    
    0 讨论(0)
提交回复
热议问题