I have developed a Python/Flask application and ran into an issue implementing a Bootstrap alert where the idea is to:
- dismissible via a close button.
- fade out and close after 2s if no action is taken.
Code
<div class="container">
{% for message in get_flashed_messages() %}
<script>
function close_alert()
{
document.getElementById("my_alert").close()
}
setTimeout("close_alert()", 2000)
</script>
<div id="my_alert" class="alert alert-primary alert-dismissible fade show" role="alert">
<strong>{{message}}</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
</div>
I'm fairly new to Bootstrap and I would appreciate any support!
Thanks!