JSFiddle - React, Tailwind, and code Playground

HTML

<p>
  Check this checkbox:
</p>

<input type="checkbox" id="checkbox1" name="checkbox" onchange="action()" />

JavaScript

var cb = document.getElementById("checkbox1");
function action() {
		
  if( confirm ( "Are you sure ?") === false )  {
    cb.checked = !cb.checked;
  }

}