title: JQuery - How do I get this function to run once when clicking twice
body: <p>I'm trying to get this function to run once when I click twice on the button element two times (not double clikcing, just clicking twice on it at any point in time) that initializes it and then make it reset.</p>
  
  <pre><code>&lt;a href="#" onclick="popHover()"&gt;
  
  $('.challenge_popover').popover()
  
  var clicked = false
  
  function popHover() {
  
          // I NEED THIS PART TO RUN ON THE FIRST CLICK
          if (clicked == false)
          {
          $('.challenge_popover').popover('destroy')
          }
  
           // AND THIS PART TO RUN ON THE SECOND CLICK
          $(document).live('mousedown', function(e) { 
  
              if (e.which == 1)  
  
              {
              $('.challenge_popover').popover()
              clicked = true
              }
  
          });
  
  }
  </code></pre>