我试图设置默认导航栏标签时,网页加载。我试图设置默认导航栏标签是'卖我的车'这个标签是打开时,页面加载。我该怎么做有导航栏选项卡。
function Default() {
var tab= document.getElementsByClassName('defaulttab');
window.onload(tab).click();
}
<a class="nav-link tablink active" id="v-pills-home-tab" data-toggle="pill" href="#my-adverts" role="tab" aria-controls="v-pills-home" aria-selected="true">My Adverts</a>
<a class="nav-link tablink defaulttab" id="v-pills-profile-tab " data-toggle="pill" href="#sell-your-car" role="tab" aria-controls="v-pills-profile" aria-selected="false">Sell my car</a>
<a class="nav-link tablink" id="v-pills-messages-tab" data-toggle="pill" href="#change-package" role="tab" aria-controls="v-pills-messages" aria-selected="false">Change Package</a>
1条答案
按热度按时间5vf7fwbs1#
只需在默认导航链接上设置
active
class,不需要额外的js: