Using Bootstrap and created a save button on which you run a specific function selector()
. This function will be executed only after saving in the bank, then it will show an alert that will disappear in a few moments. However it is only running once and not more. (I know it's extremely simple)
function selector() {
$(".alert").removeClass('hidden');
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 4000);
}
body{
padding: 30px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="alert alert-success hidden" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Congratulations!</strong> Saved successfully!
</div>
<button style="margin: 10px" type="button" onClick="$(selector).click()" class="btn btn-primary" data-toggle="modal" data-target="#category">save</button>
How does it have to be done for the alert to appear every time the selector()
function is executed?