[英]Bootstrap alert is show at page load in asp.net
I tiny confused because the bootstrap alert is shown at page load in asp.net here is the code:- 我有点困惑,因为启动警报显示在asp.net的页面加载中,这是代码:-
<div class="col-lg-12">
<div class="alert alert-danger alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</div>
I want to show some alert message on when some task is performed. 我想在执行某些任务时显示一些警报消息。
I've added a completely basic example explaining your doubt. 我添加了一个完全基本的示例来解释您的疑问。 The alert message is visible on load as you are not hiding your message in any scenario. 警报消息在加载时可见,因为您在任何情况下都不会隐藏消息。
In the below-given code snippet, I am displaying the alert message on a button click using jQuery - .show()
. 在下面给出的代码片段中,我使用.show()
在单击按钮时显示了警告消息。 On load the alert message is hidden using css - display: none
. 在加载时,警报消息使用css- display: none
隐藏display: none
。
$(document).ready(function(){ $('.btn-danger').click(function(){ $('.alert').show(); }) });
.alert { display: none; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <div class="col-lg-12"> <div class="alert alert-danger alert-dismissable"> <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> <label>Danger!</label> </div> </div> <div class="col-lg-12"> <button type="button" class="btn btn-danger">Show Alert</button> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.