I want to use a jQuery switch to add a class depending on a variable.
Is it as easy as just adding it like this:
This is how I would do it in php environment:
( jQuery is called in the header )
Can I call it in a js function?
Is it as easy as just adding it like this:
This is how I would do it in php environment:
( jQuery is called in the header )
Code:
<script type[COLOR=#339933]=[/COLOR][COLOR=#3366CC]"text/javascript"[/COLOR]>
var jsLang = 'jquery';
switch (jsLang) {
case 'jquery':
alert('jQuery Wins!');
break;
case 'prototype':
alert('prototype Wins!');
break;
case 'mootools':
alert('mootools Wins!');
break;
case 'dojo':
alert('dojo Wins!');
break;
default:
alert('Nobody Wins!');
}
//outputs "jQuery Wins!"
</script>
Comment