Answer the question
In order to leave comments, you need to log in
Auto-close alert in Bootstrap 3?
Hey!
There is a feedback form with two alerts about the successful sending of a letter or an error.
How can I make this alert auto-close after a certain time?
The difficulty is that they are formed in php when sending a letter.
Is it possible to write the solution directly in the php file, or is there a js script for auto-closing alerts if they appear on the page?
Here is the code:
$result = '';
if (mail ($to, $subject, $body, $headers)) {
$result .= '<div class="alert alert-success alert-dismissible" role="alert">';
$result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>';
$result .= 'УСПЕШНО ОТПРАВЛЕНО!';
$result .= '</div>';
echo $result;
die();
}
$result = '';
$result .= '<div class="alert alert-danger alert-dismissible" role="alert">';
$result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>';
$result .= 'ОШИБКА ОТПРАВКИ';
$result .= '</div>';
echo $result;
Answer the question
In order to leave comments, you need to log in
Use https://ned.im/noty/#/
Customize how you want. As a result, you will get what you need.
Or insert a timeout and call the code.
$(".alert").fadeOut();
$(".alert").slideUp();
$(".alert").hide();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question