title: jQuery: How to detect if an element is not clicked?
body: <p>I'd like to know if it is possible to detect if an element is not clicked. This is the code I have:</p>
  
  <pre><code>$("#mpElement").myFeature({
              .........
              .........
              .........
      afterDo: function() {
          // This if-else statement has to go inside "when not clicked" condition. 
          // Not sure how to do this...
          if($(".myButton").last().hasClass("selected")) {
              $(".myButton").first().addClass("selected");
              $(".myButton").last().removeClass("selected");
          } else {
              $(".selected").removeClass("selected").next().addClass("selected");
          }
          $(".myButton").on("click", function(){
              $(".myButton").removeClass("selected");
              $(this).closest(".myButton").addClass("selected"); 
          });
      }
  });
  </code></pre>
  
  <p>You will notice <strong>$(".myButton").on("click", function(){</strong> for detecting click event. I'd like to put the if-else statements above this function inside <strong>when not clicked</strong> condition. Not sure how to do this.</p>