Reputation: 149
I'm trying to make an effect where all the vowels are in a different font from the consonants.
Is there a way to select only 'a, e, i, o, u' and apply .css("font-family", "mycustomfont");
Trying to avoid having to out all the vowels. All suggestions appreciated!
Upvotes: 1
Views: 2221
Reputation: 94101
http://jsfiddle.net/elclanrs/rAKvB/
var str = 'Hello World',
letters = '';
for (var i = 0, len = str.length; i < len; i++) {
if (str[i].match(/[aeiou]/i)) {
letters += '<span class="vowel">' + str[i] + '</span>';
} else {
letters += '<span class="consonant">' + str[i] + '</span>';
}
}
Upvotes: 3