I have a webpage where only registered users can be.
I use Bootstrap as CSS Framework.
If the user logged in there will be a alert box with a successmessage like this:
<div class="container">
<div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success!</strong> You have been signed in successfully!
</div>
</div>
Now i want to close this after a few seconds. I use this jquery script to do that:
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 1500);
How can I run this code only once, so that if the user accidently refreshed the browser does not see this alert again ?
I've read this post here https://stackoverflow.com/a/23859937/5930557
and know that it can be done with the .one()
function from http://api.jquery.com/one/
But i dont know how to include it into my code. Is someone there who can correct it for me and explain, cause jquery and javascript are new to me :P