186
rated 0 times
[
189]
[
3]
/ answers: 1 / hits: 47032
/ 13 Years ago, thu, september 15, 2011, 12:00:00
This is the structure of the if-else statement I am using:
$('.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
}
});
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?
More From » jquery