Skip to main content
1 of 2
r_31415
  • 137
  • 6

I'm not sure about this but I think you can use your own manager in order to keep spaghetti code to a minimum.

Demo: http://jsfiddle.net/8C5wR/

function ClickManager(element) {
 this.el = $(element);
 this.check = function(){
   if (this.el.hasClass('class1')) {
    console.log('class 1 detected'); 
   }
   
   if (this.el.hasClass('class2')) {
    console.log('class 2 detected'); 
   }
   
   if (this.el.hasClass('class3')){
    console.log('class 3 detected'); 
   }
   };
}

(function(){
    $('.class1, .class2, .class3').on('click', function(){
      manager = new ClickManager($(this));
      manager.check();
    });
})();​

Maybe others can weigh in to point out possible fallouts of this.

r_31415
  • 137
  • 6