我在遇到一些if语句时试图用jQuery调用引导警报。
这是我的HTML代码:
<div class="alert alert-warning fade" role="alert" id="myAlert">
<h4 class="alert-heading">Attention</h4>
<p>You haven't select the metrial you need</p>
<hr>
<p class="mb-0">Are you going to check next step anyway?</p>
<button type="button" class="btn btn-primary">Yes</button>
<button type="button" class="btn btn-secondary">No</button>
</div>
这是我的jQuery代码:
if ($("#checkbox1").prop('checked')==false){
$(".alert").addClass('in');
return false;
}
我想在不像我上面写的那样选中一个特定复选框的情况下呼叫此警报。
我也想提到:加载页面时,我使用$(".alert").hide();
隐藏了我的警报-不确定是否正确。
我想知道当满足特定条件时如何调用此警报,以及如何正确隐藏它。
谢谢
您可以通过如下切换CSS显示属性来执行此操作: