sonia maklouf sonia maklouf - 2 months ago 11
jQuery Question

Bootstrap tabs block after hovering over theme

I've got 4 verticals pills and they show the content when I hover over them but after I hover one time over them they're not working anymore.
I've made a demo on Codepen here.

My goal is to show the active test 1 tab by default and the other (test 2 3 and 4) when we click or hover over them.

<div class="container">
<h3>Vertical Pills</h3>
<div class="row">
<div class="nav nav-pills nav-stacked col-xs-3" >
<li role="presentation" class="active"><a href="#one" aria-controls="popular" role="tab" data-toggle="tab"><h3>test 1</h3></a></li>
<li role="presentation"><a href="#two" aria-controls="latest" role="tab" data-toggle="tab"><h3>test 2</h3></a></li>
<li role="presentation"><a href="#three" aria-controls="xcomments" role="tab" data-toggle="tab"><h3>test 3</h3></a></li>
<li role="presentation"><a href="#four" aria-controls="tags" role="tab" data-toggle="tab"><h3>test 4</h3></a></li>
</div>
<div class="tab-content col-xs-9">
<div class="tab-pane active" id="one">
<div class="row">
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
</div>
</div>
<div class="tab-pane" id="two">
<div class="row">
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
</div>
</div>
<div class="tab-pane active" id="three">
<div class="row">
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
</div>
</div>
<div class="tab-pane active" id="four">
<div class="row">
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
<div class="col-xs-3">
<figure >
<span class="widgetimage"><a href="http://lorempixel.com/200/200/"></a></span><figcaption></figcaption>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</figure></div>
</div>
</div>


and the js file

$(document).on('mouseenter', '[data-toggle="tab"]', function () {
$(this).tab('show');
});

Answer

Your vertical pill il elements are not placed in a ul element but in a div element. Changing the div element to a ul element fixed your bug.

You can check out a working example here: https://codepen.io/anon/pen/pEZXom.

Comments