title: Javascript: change onclick action of elements after adding a class
body: <p>I have a situation like this:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;span class="element e1" id="FirstElement" onclick="Javascript:alert(this.id)"&gt; 
      &lt;span class="element e2" id="SecondElement" onclick="Javascript:alert(this.id)"&gt; ELEMENT &lt;/span&gt;
  &lt;/span&gt;
  &lt;button class="addButton"&gt; ADD CLASS &lt;/button&gt;
  </code></pre>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>$(document).ready(function() {
      $('span.element.anotherClass').click(function(e) {
            alert("ANOTHER ACTION"); 
            return false; // I tried also preventDefault() but not working
      });
  
      $('.addButton').click(function(e){
          $('span.element').addClass(" anotherClass");
      });
  
  });
  </code></pre>
  
  <p>Note the two <code>span</code> elements have a <code>onclick</code> action. I want that after adding a class to these elements by clicking on the button, they stop doing the old <code>onclick</code> actions and start doing the new action ( = show the "ANOTHER ACTION" alert).</p>
  
  <p>You can try the code above in <a href="http://jsfiddle.net/L5tarwh0/7/" rel="nofollow">this Fiddle</a>.</p>
  
  <p>Hope someone will help me with this problem I can't figure. Thanks</p>