I have a function thats create a element dynamically:
$('#bookUserSeat').on('click', function(){
$('#seatBookings').append('<div class="alert alert-info"><a class="deleteSeat" data-seatNumber="' + $(this).data('seatNumber') + '"><i class="fas fa-trash"></i></div>');
$('#modalBookSeat').modal('hide');
});
Now I have a function that works on the on click event:
$('#seatBookings').on('click', 'a.deleteSeat', function(){
var seat = $(this).data('seatNumber');
$(this).parent('div').remove();
});
But the var seat is empty. How can I get the data attr from the dynamically created link?