I'm trying to create a dropdown that will show google fonts for a customization website. I'm trying to apply a class to each option based on the option value. I can't just hard code it because I am working with a hosted vendor so I only have jquery/javascript abilities (otherwise I'd just add the class tag manually). Here's my HTML:
<select name="SELECT___ENG_SVC___52">
<option value="1167">Lobster</option>
<option value="1168">Shadows Into Light</option>
<option value="1169">Pacifico</option>
</select>
CSS:
.1167 {
font-size: 25px;
font-family: 'Lobster';
}
.1168 {
font-size: 25px;
font-family: 'Shadows Into Light';
}
.1169 {
font-size: 25px;
font-family: 'Shadows Into Light';
}
For my jquery/javascript, I have:
var fontname = element.options.val();
if(fontname == 1167) {
fontname.addclass(fontname.val);
}
What I'm trying to accomplish:
<select name="SELECT___ENG_SVC___52">
<option value="1167" class="1167">Lobster</option>
<option value="1168" class="1168">Shadows Into Light</option>
<option value="1169" class="1169">Pacifico</option>
</select>
fiddle: http://jsfiddle.net/sNkDW/276/
Any help would be much appreciated. Thanks in advance
UPDATE: oops, can't have class names that start with numbers. so lets make them .f1167 .f1168 and so on. can we have the jquery add an "f" in front of the option value to make it the class name?