I'm assuming the buttons don't have any other classes, and if so you can get the last digit with this.className.slice(-1)
and target all buttons with one event handler and use the last digit to get the right form :
$(function(){
$('[class^="submit"]').on('click', function() {
var n = this.className.slice(-1);
$.ajax({
type : 'POST',
url : 'delanno.php',
data : $('#myform' + n).serialize(),
beforeSend: function(){
$('#result').html('<img src="images/loading.gif" />');
}
}).done(function(data) {
$('#result').html(data);
});
$('.deleter').on('click', function(){
$(this).closest('.announce-box').remove();
});
});
});
as suggested in the comments, if the submit buttons are inside the relevant forms, you should use an actual submit button and catch the submit event, not the click event on the button :
$(function(){
$('[id^="myform"]').on('submit', function(e) {
e.preventDefault();
$.ajax({
type : 'POST',
url : 'delanno.php',
data : $(this).serialize(),
beforeSend: function(){
$('#result').html('<img src="images/loading.gif" />');
}
}).done(function(data) {
$('#result').html(data);
});
$('.deleter').on('click', function(){
$(this).closest('.announce-box').remove();
});
});
});