JSFiddle - React, Tailwind, and code Playground

HTML

<a href="#" class="posts_delete">delete</a>

JavaScript

$('.posts_delete').on('click', function(e){
    
function confirmDeletePost() {
    return confirm("This post will be removed and you can't undo this action. Are you sure you want to delete?");
}
    if(!confirmDeletePost()) {
        alert('Cancel clicked.');
        return false;
    }
    
    alert('ajax code delete continues');
    
});