在我的页面中,使用以下警告框显示来自服务器的响应:
<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>
当我点击警告框中的关闭按钮时,是否有任何方法可以将其隐藏而非从页面中移除?我尝试了这个(根据这里的说明进行),但没有成功:
$('#my-alert').on('close.bs.alert', function () {
$(this).hide();
})
更新
我也尝试了这个:
$('button.close').on("click", function(){
$(this).parent().hide();
});
但是仍然存在同样的问题,当我点击关闭按钮时,警告提示被移除。
hide
调用删除的。 - Ram