需要替换特定字词的字体 [英] Need to replace font for a particular word
本文介绍了需要替换特定字词的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将字体系列(Arial)更改为HTML文档中出现的单词'AAAAA'。这个词可以来自DB多次,但我需要替换单个字的字体一个。
I want to change the Font family(Arial) to a word 'AAAAA' that was present in a HTML document. That word can comes many times from DB but I need to replace the font for that single word alone.
我认为这将由JavaScript完成。任何人都知道如何做吗?
I think it will done by JavaScript. Could any one knows how to do it?
推荐答案
我们需要Georgia
Let's say we need Georgia
.geo{
font-family:Georgia;
font-style:italic;
font-weight:bold;
font-size:19px;
}
演示
demo
var $els = $('body *'); // iterate through all elements // or define specific for performance.
$els.each(function(){
$(this).html($(this).text().replace(/AAAAA/g, '<span class="geo">AAAAA</span>'));
});
如果< span>
你的问题(通常通过DOM使用)...我建议使用< font>
:< font class = > AAAAA< / font>
IF the <span>
could give you problems (as commonly used through the DOM) ... I'd suggest to use <font>
: <font class="geo">AAAAA</font>
这篇关于需要替换特定字词的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文