Ok The html code that matches the unicode character of the 004D font is " M ". Since you want to change all occurrences of the "M" qualifier to this particular character, just find the occurrences of that character and add the span tag on the fly.
Here is an example where I did the same with the symbol "e", but not the "E". I changed "e" to "Θ"
JSFIDDLE LINK here.
$(document).ready(function() { $.fn.texter = function() { var letters = $(this).html().split(""), text = ""; for (var i in letters) { if (letters[i] == "e") { text += "<span class='" + letters[i] + "'>" + 'ȝ' + "</span>"; } else { text += letters[i]; } } $(this).html(text); }; $("body").texter(); });
.e { color: magenta; font-family: 'Arial'; font-size: 18px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <div class="text">Test Message is Entered Here EEE is not touched but eee is changed</div>
Another option is to use the "unicode-range" attribute in @ font-face to indicate a new font and apply this new font to each occurrence of a character. Refer to the MDN Documentation here .
The script for this can be found here: http://jsfiddle.net/dka30drt/7/
The fragment code is here for the second option,
$(document).ready(function() { $.fn.texter = function() { var letters = $(this).html().split(""), text = ""; for (var i in letters) { if (letters[i] == "e") { text += "<span class='" + letters[i] + "'>" + 'ȝ' + "</span>"; console.log(letters[i]); } else { text += letters[i]; } } $(this).html(text); }; $("body").texter(); });
@font-face { font-family: funkyfont; src: url(https://www.courts.mo.gov/civiceducation/html5bp/html5-boilerplate-4.3.0/css/webfontkit/alegreyasc-italic-webfont.eot?#iefix) format('embedded-opentype'), url(https://www.courts.mo.gov/civiceducation/html5bp/html5-boilerplate-4.3.0/css/webfontkit/alegreyasc-italic-webfont.woff) format('woff'), url(https://www.courts.mo.gov/civiceducation/html5bp/html5-boilerplate-4.3.0/css/webfontkit/alegreyasc-italic-webfont.ttf) format('truetype'), url(https://www.courts.mo.gov/civiceducation/html5bp/html5-boilerplate-4.3.0/css/webfontkit/alegreyasc-italic-webfont.svg#svgFontName) format('svg'); unicode-range: U+004D; } .e { color: magenta; font-family: 'funkyfont'; font-size: 18px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="text">Test Message is Entered Here EEE is not touched but eee is changed</div>
Hope this helps
source share