使用最新的引导程序,我创建了一条带有链接的固定警报消息,该消息在单击时会打开一个模式。屏幕上显示模式POPS-UP,但警报保持打开状态。
当弹出模式时如何消除警报?
我尝试使用data-dismiss="alert"
在使用data-toggle="modal" data-target="#privacyterms"
打开模态的同一链接上,现在警报将不会消失,模态将无法正常工作。我究竟做错了什么? Bootstrap或jQuery是否可以解决此问题?
<div class="text-center alert alert-info alert-dismissible alert-fixed m-0" role="alert">
<button type="button" class="close " data-dismiss="alert"><span style="font-size:30px;" class="" aria-hidden="true">×</span></button>
<strong>We use cookies!</strong> By continuing to use this site you're agreeing to our terms and privacy policy.<a href="#" data-toggle="modal" data-dismiss="alert" data-target="#privacyterms"> Learn more?</a>
<button data-dismiss="alert" type="button" class="btn btn-secondary">I agree</button>
</div>
这是我的工作Fiddle,它丢失了链接上的data-dismiss = alert,但也许有人可以使用它来提出更好的解决方案。
感谢您的帮助!
我将使用Bootstrap提供的事件方法:
$('#privacyterms').on('show.bs.modal', function() {
$('#cookieAlert').alert('close');
});
https://getbootstrap.com/docs/4.0/components/modal/#methodshttps://getbootstrap.com/docs/4.0/components/alerts/#methods