cuốn sách gpt4 ai đã làm

javascript - 单击 popover 触发元素时如何关闭/关闭 Bootstrap Popover?

In lại Tác giả: Hồ Xil 更新时间:2023-11-01 02:13:59 25 4
mua khóa gpt4 Nike

jsFiddle:http://jsfiddle.net/kAYyR/

截图:

screenshot

这是有效的:

  1. 点击按钮打开弹出框
  2. 在弹出框外点击关闭弹出框
  3. 点击 .close 按钮关闭弹出窗口

但是...当您再次单击原始按钮时,我无法关闭弹出窗口。取而代之的是,弹出窗口会闪烁,然后再次闪烁。

自己复制đây .

Làm thế nào tôi có thể làm điều này?

HTML:


This rich
html
content goes inside popover

JS:

$('#popoverId').popover({
html: true,
title: "Popover Title",
content: function () {
return $('#popoverContent').html();
}
});


var isVisible = false;
var clickedAway = false;

$('.popoverThis').popover({
html: true,
trigger: 'manual'
}).click(function (e) {
$(this).popover('show');
$('.popover-content').append('×');
clickedAway = false
isVisible = true
e.preventDefault()
});

$(document).click(function (e) {
if (isVisible & clickedAway) {
$('.popoverThis').popover('hide')
isVisible = clickedAway = false
} khác {
clickedAway = true
}
});

câu trả lời hay nhất

你想要这样的工作吗?

http://jsfiddle.net/kAYyR/3/

$('#popoverId').popover({
html: true,
title: 'Popover Title×',
content: $('#popoverContent').html(),
});

$('#popoverId').click(function (e) {
e.stopPropagation();
});

$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('#popoverId').popover('hide');
}
});

关于javascript - 单击 popover 触发元素时如何关闭/关闭 Bootstrap Popover?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15944698/

25 4 0
Hồ Xil
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress