JS:
$(function(){
$("#example").popover({
placement: 'bottom',
html: 'true',
title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">×</button>',
content : 'test'
})
$('html').click(function() {
$('#close').popover('hide');
});
});
HTML:
<button type="button" id="example" class="btn btn-primary" ></button>
i'm write your code isn't show your popup.
anyone come across this problem?
This works with multiple popovers and I also added a little big of extra JS to handle the z-index issues that happen with overlapping popovers:
http://jsfiddle.net/erik1337/fvE22/
JavaScript:
HTML:
CSS:
Put this in your title popover constructor...
...to get a small red 'x' button on top-right corner
For me this is the simplest solution to add a close button in a popover.
HTML:
Javascript:
I found the code below very useful (taken from https://www.emanueletessore.com/twitter-bootstrap-popover-add-close-button/):
Just wanted to update the answer. As per Swashata Ghosh, the following is a simpler way that worked for moi:
HTML:
JS:
I've checked many of the mentioned code examples and for me the approach from Chris is working perfectly. I've added my code here to have a working demo of it.
I have tested it with Bootstrap 3.3.1 and I haven't tested it with an older version. But it's definitely not working with 2.x because the
shown.bs.popover
event was introduced with 3.x.