2
How to do to the navbar
of Bootstrap 4.1 vary between the contents when clicked on them, I created the nav
following the example of the site.
To navbar
open her items need to add action with js in it? How do I?
I tried so:
$('#nav-home').on('hide.bs.tab', function (e) {
e.target // newly activated tab
e.relatedTarget // previous active tab
});
$('#nav-perfil').on('hide.bs.tab', function (e) {
e.target // newly activated tab
e.relatedTarget // previous active tab
});
Navbars:
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Home</a>
<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</a>
</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">...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
</div>
Which version of Bootstrap?
– hugocsl
You want to build a Menu, or a Tabs system that changes the contents, like this: https://getbootstrap.com/docs/4.0/components/navs/#tabs
– hugocsl
Tabs system, https://getbootstrap.com/docs/4.0/components/navs/#javascript-behavior
– João Miguel
Guy posted an answer, qq doubt comments there, and if I have misunderstood tell me that I can remove the beauty answer
– hugocsl
What version of jQuery you are using?
– Sam