You can also create an HTML warning template as follows:
<div class="alert alert-info" id="alert_template" style="display: none;"> <button type="button" class="close">×</button> </div>
And you can do it in JavaScript here:
$("#alert_template button").after('<span>Some text</span>'); $('#alert_template').fadeIn('slow');
It is, in my opinion, cleaner and faster. Additionally, you use Twitter Bootstrap standards when calling fadeIn() .
To ensure that this warning pattern also works with multiple calls (therefore, it does not add a new message to the old one), add this here in your JavaScript:
$('#alert_template .close').click(function(e) { $("#alert_template span").remove(); });
Thus, this call removes the span every time you close the warning with the x button.
pvlsgnnks May 23 '13 at 12:31 2013-05-23 12:31
source share