EDIT: Added a fiddle to demonstrate it: http://jsfiddle.net/Myw4H/
Assume that I have the following HTML markup:
<div class="bigicon icon">
  <img id="newItems" alt="New items" src="Resources/Icons/MailNewItemMenu.png" />
  <div class="iconlegend">
    New<br />Items
  <i class="fa fa-caret-down"></i>
</div>
Now, I want to execute an action when I click on it. This can be done with the following javascript:
$(".icon").click(function(e) {
    // When the icon holds a menu, show the menu.
    if ($(this).children(".menu").length > 0) {
        e.stopPropagation();
        $(".menu", this).first().EnableMenu(100, $(this));
     }
});
That's all working fine, but now let's change the HTML to disable the icon:
<div class="bigicon icon disabled">
  <img id="newItems" alt="New items" src="Resources/Icons/MailNewItemMenu.png" />
  <div class="iconlegend">
    New<br />Items
  <i class="fa fa-caret-down"></i>
</div>
Note: See the 'disabled' class on the outer div.
Now, I change my event to, what I believe, only applies to icons that are not disabled:
$(".icon:not(.disabled)").click(function(e) {
    // When the icon holds a menu, show the menu.
    if ($(this).children(".menu").length > 0) {
        e.stopPropagation();
        $(".menu", this).first().EnableMenu(100, $(this));
     }
});
However, the event is still fired event when the icon is disabled and I click on it.
Note: For the information, I'm adding the class disabled at runtime (through a javascript function).
Someone who can explain why this is happening and how to solve it?
 
     
    