开发者

Change font for £ after page loaded

I have a situation where the font in a H3 element is being replace by Cufon with a font that does not have a pound 开发者_如何学运维L (£).

As a quick fix I want to replace any £ in H3 element with a different font AFTER cufon has done it's thing.

I think jQuery can do this. I guess it will have to replace the £ with a span tag which calls a different font?


Previous answer changes font for whole element, this does just the one character.

$('h3').each(function() {$(this).html($(this).html().replace('&pound;','<span font="your font">&pound;</span>'));});


This checks all h3 elements with the "oldFont" class for occurrences of the "£" character and wraps them all in a span with a class of "newFont":

$("h3.oldFont").each(function() {
   $(this).html($(this).html().replace(/£/g, "<span class='newFont'>£</span>")); 
});


$(document).ready(function(){
    $("h3:contains('£')").css('font-face','Arial');

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜