Switch case in jquery

Posted by Jasl on Stack Overflow See other posts from Stack Overflow or by Jasl
Published on 2010-04-23T05:36:02Z Indexed on 2010/04/23 5:43 UTC
Read the original article Hit count: 262

Filed under:

Am I writing the correct switch case?

var cnt = $("#div1 p").length;
                alert(cnt);
                switch (cnt) {
                    case (cnt >= 10 && cnt <= 20):
                        alert('10');
                        break;
                    case (cnt >= 21 && cnt <= 30):
                       alert('21');
                        break;
                    case (cnt >= 31 && cnt <= 40):
               alert('31');
                        break;
                    default:
                        alert('>41');
                }

For some reason, the alert does not occur when the conditions are matched!

© Stack Overflow or respective owner

Related posts about jQuery