[英]popover is not hiding when click on the screen
im trying to fix a popover on an image click im trying to do something like in the way that if i click on the image the popover shows if i agian click the image it hides, but i want something more if i click out of the image and popover it sholud be hide any help would be appriciated, thanks. 即时消息试图修复图像上的弹出窗口,即时消息尝试做类似的方式,如果我单击该图像,弹出窗口显示如果我agian单击它隐藏的图像,但是如果我单击该图像,我想要更多内容和弹出框应该掩饰任何帮助将被应用,谢谢。
$("#popup-img").click(function () {
if ($(".popup").is(":hidden")) {
$(".popup").slideDown("fast");
} else {
$(".popup").slideUp("fast");
}
if ($(".popup").is(":visible")) {
// i thin here code should be if i click out of the popover
// it should be hide again
}
});
$("#popup-img").click(function () {
if ($(".popup").is(":hidden")) {
$(".popup").slideDown("fast");
}
});
$(window).click(function () {
if ($(".popup").is(": visible")) {
$(".popup").slideUp("fast");
}
});
I think you want something like: 我认为您想要类似的东西:
$("#popup-img").click(function () {
$(".popup").slideDown("fast");
$("body").click(function() {
$(this).unbind("click");
$(".popup").slideUp("fast");
}
});
If your using bootstrap as indicated by the tag this is very simple since bootstrap provides this functionality by default: 如果您使用标记指示的引导程序,这将非常简单,因为引导程序默认提供以下功能:
HTML 的HTML
<div id="popup-img"> Click</div>
<div class="popup modal hide">This is a popup</div>
Javascript Java脚本
$("#popup-img").click(function(){
$(".popup").modal();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.