I'm a beginner when it comes to jQuery. I have a form that calculates and displays the result in a flash message. My desired behavior is as follows:
- When the form is submitted for the first time, the flash message with the results should fade in.
- For subsequent submissions, the old flash message should fade out before the new one fades in.
I'm having trouble achieving this because both the old and new results share the same id.
Currently, only the fade in effect is working properly.
JavaScript (jQuery):
$(function() {
$(".btn-primary").click(function() {
$("#diagnosis").fadeOut("slow");
});
$('#diagnosis').delay(0).fadeIn('normal', function() {
$(this).delay(2500);
});
});
CSS:
#diagnosis { display:none; }