I tiny confused because the bootstrap alert is shown at page load in asp.net here is the code:-
<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()
. On load the alert message is hidden using css - 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.