title: jQuery: does not add class to tag or instantly removes it, respectively
body: <p>First of all, i am new to jQuery. It is no rocket science to create a simple program, but the effect of the following code doesn't make any sense to me. My intention is that after an element with a class ".button" was clicked a new class should be added to that element. Otherwise - clicking somewhere else - the present new class should be removed. Unfortunately, the code in else is executed, even though the condition is true. What are the flaws of my idea? Could you provide a solution to that problem.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    $("*").click(function() {
      var ret = $(this).hasClass("button");
  
      if (ret) {
        $(".button").addClass("newclass");
      } else {
        $(".button").removeClass("newclass");
      }
    });
  
    $("form").on("submit", function() {
      return false;
    })
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.newclass {
    color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form method="get" action=""&gt;
    &lt;input type="text" name=""&gt;
    &lt;input type="submit" name="" class="button"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>