K
K
kaleon2019-02-27 04:12:56
JavaScript
kaleon, 2019-02-27 04:12:56

How to get a second alert after closing the old one?

The code is triggered by a button. If you close it after the first time, then the alert will no longer be shown, because it does not find error-alert.
JS

if (!var) {
        return document.getElementById('error-alert').style.display = 'block';
}

HTML
<div id="alerts">
    <div id="error-alert" class="alert alert-danger alert-dismissible fade show" role="alert" style="display: none;">
         <button type="button" class="close" data-dismiss="alert">&times;</button>
         <strong>Ошибка!</strong> 
   </div>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Esin, 2019-02-27
@Exomode

It should be understood that your code runs linearly at runtime and most of the checks will run immediately after the DOM is loaded. If you need checks and events to work after the document is lazy loaded, you need to change the logic of your code. For example, hang up your check and show an alert on a timeout or a button click event, then the alert will be shown by condition after the document is loaded.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question