When I submit my form, I display a message in jQuery.
I want it appears only once when I submit more than once
$('form').submit(function(){
if ($('#title').val() != '' && $('#comment').val() != '')
$('form').append($('<span>').text('Bug sent').delay(4000).fadeOut(600));
else
$('form').append($('<span>').text('Fields are empty').delay(4000).fadeOut(600));
return false;
});
Example : http://jsfiddle.net/bUS8e/
Simply remove any existing
spans in the form: http://jsfiddle.net/pimvdb/bUS8e/1/.Note that this would also remove any other, irrelevant
spans which you might not want to have removed. In that case, you can add a class to the messagespans you add, and use$('form span.message').remove();so that only those messagespans get removed.