当显示Bootstrap警报时,我想留下直到用户明确驳回它。但是,我的所有警报都会在5秒内消失。如何更改此行为?
我目前的提醒代码:
<div class="alert alert-dismissible alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button><b>Error:</b> Error message...</div>
尝试删除alert-dismissible
课程,但没有帮助。
答案 0 :(得分:0)
试试这个:
$(document).ready(function() {
$('button').click(function() {
$('.alert').show()
});
$('button').click(function() {
$(this).parents('div').hide();
});
});
.alert {
display: none;
}
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" />
<body>
<button type="submit" class="btn btn-primary">Submit</button>
<div class="alert alert-dismissible alert-success">
<button type="button" class="close">×</button>
<strong>Completed!</strong> Form successfully submitted...
</div>
</body>
答案 1 :(得分:0)
这似乎是将“警报”作为类添加的结果。以下对我有用:
<div style="padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px" class="alert-dismissible alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button><b>Error:</b> Error message...</div>