bootstrap 4 open tab when opening modal

To open a tab when opening a modal in Bootstrap 4, you can use the show.bs.modal event and the tab('show') method. Here's an example of how you can achieve this:

<!-- HTML -->
<div class="modal" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal body -->
      <div class="modal-body">
        <!-- Nav tabs -->
        <ul class="nav nav-tabs">
          <li class="nav-item">
            <a class="nav-link active" data-toggle="tab" href="#home">Home</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" data-toggle="tab" href="#profile">Profile</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" data-toggle="tab" href="#messages">Messages</a>
          </li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
          <div class="tab-pane active" id="home">Home tab content</div>
          <div class="tab-pane" id="profile">Profile tab content</div>
          <div class="tab-pane" id="messages">Messages tab content</div>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- JavaScript -->
<script>
  $('#myModal').on('show.bs.modal', function () {
    $('#home').tab('show');
  });
</script>

In this example, the show.bs.modal event is triggered when the modal is about to be shown. Inside the event handler, we use the tab('show') method to show the "Home" tab by default. You can modify the code to show a different tab by changing the href value and the corresponding tab content.

Please note that this code assumes you have already included the necessary Bootstrap 4 CSS and JavaScript files in your project.

I hope this helps!