I have created some tabs in bootstrap and i would like to display the tabs onmouseover
This are the tabs https://jsfiddle.net/uzfxmrs3/
This is the html
<div class="d-flex align-items-start responsive-tab-menu">
<ul class="nav flex-column nav-pills nav-tabs-dropdown me-3" id="v-pills-tab" role="tablist"
aria-orientation="vertical">
<li class="nav-item">
<a class="nav-link text-start active" href="#" id="v-pills-home-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-start" href="#" id="v-pills-profile-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-profile" role="tab" aria-controls="v-pills-profile"
aria-selected="false">Profile</a>
</li>
</ul>
<div class="tab-content responsive-tab-content" id="v-pills-tabContent" style="border:1px solid #708090; width:600px;height:200px;">
<div class="tab-pane fade" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab"
tabindex="0">home content</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab"
tabindex="0">profile content</div>
</div>
</div>
and this is the jquery
$('.nav-tabs-dropdown')
.on("mouseover", ".nav-link:not('.active')", function (event) {
$(this).closest('ul').removeClass("open");
})
.on("mouseover", ".nav-link.active", function (event) {
$(this).closest('ul').toggleClass("open");
});
Currently the code only displays the content on click.
3
Answers
I made the vertical menus to only show on hover/mouseover like this
https://jsfiddle.net/8jn240b5/
You can change your jQuery to something like this:
Add
$(this).tab('show');
as follows:Replace your javascript code with this: