2
Using Bootstrap and created a button save in which it performs 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 running only once and not anymore. (I know it is something 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>
<link href="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 it has to be done so that the alert appears every time the function is executed selector()
?
Why not use toastr ? It is much easier and practical.
– Matheus Miranda
@Matheusmiranda looks like an alternative. vlw
– viana