title: How to write a switch statement in jQuery/Javascript to test if an element has a particular class?
body: <p>This is the structure of the if-else statement I am using:</p>
  
  <pre><code>$('.myclass a').click(function() {
     if ($(this).hasClass('class1')) {
          //do something
     } else if ($(this).hasClass('class2')) {
          //do something
     } else if ($(this).hasClass('class3')) {
          //do something
     } else if ($(this).hasClass('class4')) {
          //do something
     } else {
          //do something
     }
  });
  </code></pre>
  
  <p>There are quite a number of cases already and I thought using a switch statement would be neater. How do I do it in jQuery/javascript?</p>