我想在一个项目中添加一个弹出窗口,该项目位于导航栏中的下拉菜单中。
所以在悬停时应该出现弹出窗口。
有人可以帮我创建吗?
答案 0 :(得分:1)
请使用以下代码在Dropdown菜单上显示popover,这是正常工作的fiddle
<强> HTML 强>
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li id="ex1"><a href="#">Example 1</a></li>
<li id="ex2"><a href="#">Example 2</a></li>
<li id="ex3"><a href="#">Example 3</a></li>
<li id="ex5"><a href="#">Example 4</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<强> jquery的强>
$(function () {
var showPopover = function () {
$(this).popover('show');
}
, hidePopover = function () {
$(this).popover('hide');
};
$('#ex1').popover({
content: 'An Example1 popover',
trigger: 'hover',
placement:'top'
})
$('#ex2').popover({
content: 'An Example2 popover',
trigger: 'hover',
placement:'top'
})
$('#ex3').popover({
content: 'An Example3 popover',
trigger: 'hover',
placement:'top'
})
});