Sow*_*mya 2 javascript jquery popover twitter-bootstrap
如何通过单击popover外部来解除Bootstrap popover.目前它已切换为开放链接.
HTML
<div class="widget-rating">
<span class="rateit rating-average"></span>
<a class="btn btn-mini" href="javascript:void(0)"><b class="caret"></b></a>
</div>
Run Code Online (Sandbox Code Playgroud)
这是js代码
element.popoverAnchor.popover({
title: "Rating",
animation: false,
html: true,
content: "Loading...",
placement: "bottom",
trigger: "click"
});
Run Code Online (Sandbox Code Playgroud)
$('body').on('click', function (e) {
$('.popover-link').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
Run Code Online (Sandbox Code Playgroud)
参考:http://mattlockyer.com/2013/04/08/close-a-twitter-bootstrap-popover-when-clicking-outside/
| 归档时间: |
|
| 查看次数: |
3655 次 |
| 最近记录: |