我的引导程序警报不适用于CSS动画类fadeout
。正如BS文档closed.bs.alert
中提到的那样:This event is fired when the alert has been closed (will wait for CSS transitions to complete).
但是我想要消退并且发出警报。
$('.alert').each(function(index, el) {
$(this).on('closed.bs.alert', function(){
$(this).addClass('animated fadeOut')
})
});
我可以使用jQuery fadeOut
方法和slideUp
来完成这项工作吗?
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<p><i class="fa fa-check"></i> <strong>Success Message ! </strong>You have successfully registered</p>
</div>
答案 0 :(得分:0)
你需要
close.bs.alert
请参阅下面的代码。
// bind event at 'close.bs.alert'
$('.alert').on('close.bs.alert', function(e) {
// stop Bootstrap animation
e.stopPropagation();
// Use my own animation
$(this).closest('.alert')
.animate({
height: 'toggle',
opacity: 'toggle'
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="alert alert-success fade in">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<p><i class="fa fa-check"></i> <strong>Success Message ! </strong>You have successfully registered</p>
</div>
</div>
</div>
</div>
&#13;