If you're using Bootstrap 5 and need to trigger custom JavaScript code when a user selects a tab, the shown.bs.tab event is what you need. This event fires when a new tab is shown and the transition to the tab content is complete. Below, we provide a step-by-step example to help you achieve this. HTML Structure for Tabs Here's an example of a basic Bootstrap 5 tabs structure: <ul class="nav nav-tabs" id="myTab" role="tablist"> <li class="nav-item" role="presentation"> <button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button> </li> <li class="nav-item" role="presentation"> <button class="nav-link" id="profile-tab" data-bs-toggle=...