【发布时间】:2014-01-18 06:45:03
【问题描述】:
我有一个带有 3 个 Twitter 引导弹出按钮的页面,单击这些按钮会显示一个带有 HTML 内容的隐藏 div。我在右上角添加了一个 X 来关闭弹出框。
我的问题发生在弹出窗口打开并覆盖其下方的内容然后关闭时,它下方的内容即链接到另一个页面的按钮不再可访问并且您无法再单击它。
在检查器中,我可以看到隐藏的弹出框,即带有内容的 div,位于我要单击的按钮的顶部,因此我无法访问它。
奇怪的是,当我点击实际的弹出框按钮关闭弹出框时,它完全消失了,我可以点击下面的按钮,但是当我点击关闭 X 时,我不能。
我该如何解决这个问题?
页面链接:(http://bit.ly/1j1AW4i)
按钮代码:
<button id="popoverBtn1" class="popoverThis btn btn-default" data-placement='bottom'>
Learn More <span class="glyphicon glyphicon-circle-arrow-right"></span>
</button>
<div id="popoverContent1" class="hide">
<strong>Ideal for:</strong> Qualified clients who want to continue having the convenient access to funds that a home equity line of credit provides.
<br /><br />
<strong>What:</strong> Apply for a new Access 3<sup>®</sup> Equity Line and transfer your current balance to the new line. <a target="_blank" href="https://www.suntrust.com/PersonalBanking/Loans/EquityLinesOfCreditAndLoans/EquityLineOfCredit">Learn More</a> about our Access 3<sup>®</sup> Equity Line.
<br /><br />
<strong>Get started:</strong> <a target="_blank" href="https://www.suntrust.com/portal/server.pt?space=Redirect&CommunityID=1805&ui_ProdGroup=IL&ui_ProdSubGroup=EQLN&ui_Product=INETACCX&POPNAC=T">Apply Online</a>, Call <span class="blue">877-748-4059</span>, or stop by your <a target="_blank" href="https://www.suntrust.com/FindUs">local branch</a>.
</div>
脚本代码:
$('#popoverBtn1').popover({
html: true,
title: '<a class="close popoverThis">×</a>',
content: $('#popoverContent1').html(),
});
$('#popoverBtn2').popover({
html: true,
title: '<a class="close popoverThis">×</a>',
content: $('#popoverContent2').html(),
});
$('#popoverBtn3').popover({
html: true,
title: '<a class="close popoverThis">×</a>',
content: $('#popoverContent3').html(),
});
$('.popoverThis').click(function (e) {
e.stopPropagation();
});
$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('.popoverThis').popover('hide');
}
});
【问题讨论】:
-
我发现如果您使用弹出框的关闭按钮会出现问题,但如果您再次单击弹出框目标元素关闭则不会出现问题。
-
在 Linux 上的 Chrome 中测试,我似乎无法重现问题...
-
是的,isherwood,这似乎是问题所在。不幸的是,我需要在弹出框“关闭 X”上具有与按钮相同的关闭功能。
-
看看我的解决方案是否适合你。如果没有,请给我一些反馈,我会调查它。谢谢
标签: javascript jquery twitter-bootstrap button popover