【发布时间】:2014-07-20 11:57:34
【问题描述】:
在我的页面中,使用此警报显示来自服务器的响应:
<div id="yes" class="alert alert-success" role="alert" style="display: none;">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>Pronto!</strong> cadastro efetuado com sucesso!
</div>
当我单击警报中的关闭按钮时,有什么方法可以隐藏而不是从页面中删除?我尝试了这个(按照here 的说明),但没有成功:
$('#my-alert').on('close.bs.alert', function () {
$(this).hide();
})
更新
我也试试这个:
$('button.close').on("click", function(){
$(this).parent().hide();
});
但还是同样的问题,当我点击关闭按钮时,警报被删除了。
【问题讨论】:
-
hide不删除元素,这是什么问题? -
@undefined 我不想删除,但是当我单击关闭按钮时会发生这种情况。
-
该元素是由引导程序而不是
hide调用删除的。 -
我按照这个答案的说明解决了这个问题:stackoverflow.com/a/13550556/2692962