I have a page with one fixed-top navbar. Then I have 3 sections. In 2nd section I have nav-tabs. Upon scrolling into the 2nd section, I want the nav-tabs navbar to stick to top, below my fixed-top navbar. When user has scrolled out of the 2nd section, the nav-tabs navbar should disappear and only the fixed-top navbar must remain.
I can not find any tutorials or guidance related to what I'm trying to achieve. Any idea how to do this in bootstrap 5 using jquery?
index.html
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container-fluid">
<a class="navbar-brand m-1" href="#intro">Tarheeb EMS Presentation</a>
<button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarMain"
aria-controls="navbarMain" aria-expanded="false" aria-label="Toggle navigation">
<span></span>
<span></span>
<span></span>
</button>
<div class="collapse navbar-collapse" id="navbarMain">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">Introduction</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Platforms</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Comparison</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Summary</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</li>
</ul>
</div>
</nav>
<section class="1">
....
</section>
<section class="2">
<nav>
<div class="nav nav-tabs sticky" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-cvent-tab" data-bs-toggle="tab" data-bs-target="#nav-cvent"
type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Cvent</button>
<button class="nav-link active" id="nav-cvent-tab" data-bs-toggle="tab" data-bs-target="#nav-cvent"
type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Cvent</button>
<button class="nav-link active" id="nav-cvent-tab" data-bs-toggle="tab" data-bs-target="#nav-cvent"
type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Cvent</button>
<button class="nav-link active" id="nav-cvent-tab" data-bs-toggle="tab" data-bs-target="#nav-cvent"
type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Cvent</button>
<button class="nav-link active" id="nav-cvent-tab" data-bs-toggle="tab" data-bs-target="#nav-cvent"
type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Cvent</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-cvent" role="tabpanel" aria-labelledby="nav-cvent-tab">
</div>
<div class="tab-pane fade show active" id="nav-cvent" role="tabpanel" aria-labelledby="nav-cvent-tab">
</div>
<div class="tab-pane fade show active" id="nav-cvent" role="tabpanel" aria-labelledby="nav-cvent-tab">
</div>
<div class="tab-pane fade show active" id="nav-cvent" role="tabpanel" aria-labelledby="nav-cvent-tab">
</div>
<div class="tab-pane fade show active" id="nav-cvent" role="tabpanel" aria-labelledby="nav-cvent-tab">
</div>
</div>
</section>
<section class="3">
...
</section>