JSFiddle - React, Tailwind, and code Playground
HTML
<a href="eat-taco.php" data-confirm="Are you sure you want to eat the taco?">Eat taco</a>
<form action="submit-form.php" data-confirm="Are you sure you want to submit the form?">
<button type="button" data-confirm="Would you like to squeeze the lemon?">Squeeze lemon</button>
<button type="submit">Submit form</button>
</form>
JavaScript
$(function() {
$("[data-confirm]").on('click submit', function(){
return confirm($(this).data("confirm"));
});
});