<a href="https://jsfiddle.net/krishna2909/amxLak5d/">Clcik here</a>
Here in the above link I kept the code for which I'm testing. How can I change the on click functionality to on hover functionality?
<a href="https://jsfiddle.net/krishna2909/amxLak5d/">Clcik here</a>
Here in the above link I kept the code for which I'm testing. How can I change the on click functionality to on hover functionality?
Here you go with a solution https://jsfiddle.net/amxLak5d/2/
$(function(){
$('[rel="popover"]').popover({
container: 'body',
html: true,
content: function () {
var clone = $($(this).data('popover-content')).clone(true).removeClass('hide');
return clone;
},
trigger: "hover"
}).hover(function(e) {
e.preventDefault();
});
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--How to change Onclick Function to On Hover Function-->
<nav class="navbar navbar-toggleable-xl navbar-light back_trans100">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><img src="images/logo.png" class="img-responsible"></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="active">
<a href="#" rel="popover" data-placement="bottom" data-popover-content="#myPopover">My Popover</a>
<div id="myPopover" class="hide">
This is a popover list:
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
</div>
</li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
</div>
</nav>
Just add trigger: "hover"
property.
Reference document: https://www.w3schools.com/bootstrap/bootstrap_ref_js_popover.asp
Change the element with the popover to include a data-trigger with the value hover
:
<a href="#" rel="popover" data-placement="bottom" data-popover-content="#myPopover" data-trigger="hover">My Popover</a>