Q:

switch case statement based one of many classes

I'm trying to implement a switch case statement like this: 
switch (active.attr('class')){
    case "video": ...

        case "slideshow": ...
...

The problem is, that "video" and "slideshow" each are one of three classes the div I'm trying to target has, therefor it doesn't match the case... 
How would I basically say "video is a part of attr('class')" ?
Thanks, 
Lutz 

A:

It looks like you're using jQuery, which offers two methods for that:

.is()help
.hasClass()help

So you can either call:
if( active.hasClass('video') ) { }

or
if( active.is('.video') ) { }

Notice that .is() requires a more specific pattern with the leading . but it you can determine lots of other things too like .is('div') etc.

A:

You could perhaps try and split the string.
From the top of my head:
var classes = active.attr('class').split(' ');
foreach(var c in classes) {
    switch(c) {
        case 'video'
        ...
        case 'slideshow'
        ...
    }
}

Just an idea. The above answers might do the same in other ways :)
Edit: 
You could also use jQuery .each() like this:
classes.each(function(c) {
    switch(c) {
        case 'video'
        ...
        case 'slideshow'
        ...
    }
}

