use .on()
As your span is added dynamically so it is not present at the time DOM ready or page load.
So you have to use Event Delegation
Syntax
$( elements ).on( events, selector, data, handler );
like this
$(document).on('click','.delete_button',function(){
// code here
});
or
$('parentElementPresesntAtDOMready').on('click','.delete_button',function(){
// code here
});
your code becomes
$(document).ready(function () {
$(document).on('click', '.delete_button', function () {
var transaction_id = $(this).attr('id').replace('delete_', '');
alert("Delete transaction #" + transaction_id);
return false;
});
});