twitter bootstrap 3 setting active tab in js not working

前端 未结 2 1713
野的像风
野的像风 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: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')
    

提交回复
热议问题