Answer the question
In order to leave comments, you need to log in
How to activate Bootstrap 5 tab via url?
How to activate the "nav-profile" tab by typing "index.html#nav-profile" in the address bar of the browser?
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>
<button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">... tab-1 ...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">... tab-2 ...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">... tab-3 ...</div>
</div>
Answer the question
In order to leave comments, you need to log in
if (location.hash == '#profile') {
// Используя javascript-api бутстрапа активировать нужную вкладку.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question