更改特定字符的字体 [英] Changing font of Specific Characters

查看:94
本文介绍了更改特定字符的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使所有元音的字体与辅音的字体不同.

I'm trying to make an effect where all the vowels are in a different font from the consonants.

有没有办法只选择'a,e,i,o,u'并应用.css("font-family","mycustomfont");

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!

推荐答案

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>';
    }
}

这篇关于更改特定字符的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆