<分区>
<分区>
<a href="https://jsfiddle.net/krishna2909/amxLak5d/">Clcik here</a>
在上面的链接中,我保留了我正在测试的代码。如何将点击功能更改为悬停功能?
最佳答案
给您一个解决方案 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>
只需添加 trigger: "hover"
属性即可。
引用文档:https://www.w3schools.com/bootstrap/bootstrap_ref_js_popover.asp
关于javascript - 如何将 onClick 更改为 onHover 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45648595/