title: Jquery: confirm before click action
body: <p>I have a checkbox in my form. I want to ask the user for confirmation before he checks the box. However, the "confirm" message automatically comes up AFTER the box gets ticked. I want to make it so the user can "cancel", and it's as if he never checked the box to begin with.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>$( document ).ready(function() {
    $('.checkme').click(function(){
      text_area_id = "#" + $(this).val();
      if ($(text_area_id).attr('hidden')) {
        $(text_area_id).attr('hidden', false);
      } else{
        if ($(text_area_id).val() != '') {
          if (confirm("Clear text for \'" + $(this).val().replace(/_/g, " ") + "\'?")) {
            $(text_area_id).attr('hidden', true);
            $(text_area_id).val('');
            $(this).attr('checked', true);
            $('.checkme').attr('checked', true);
          }
        } else {
          $(text_area_id).attr('hidden', true);
          $('.checkme').attr('checked', true);
        }
      }
    });
  </code></pre>
  
  <p>Note the "confirm" box. I want that to come up upon clicking the checkmark box -- but BEFORE the box actually gets ticked.</p>
  
  <p>So I'm guess I'm looking for a jquery function like</p>
  
  <pre><code>.before_click(function(){ ...
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>.click(function(){ ...
  </code></pre>
  
  <p>Or something like that...?</p>