JSFiddle - React, Tailwind, and code Playground
by Amir Sharifian
HTML
<div class="myGrid">
<b style="top: 50px;">123456789-10-11-12</b>
<br />
<span style="margin: 20px 0 10px 5px">05-10-1390</span>
<a href="http://blog.jsfiddle.net/" style="left: 20px">our blog</a>
</div>
JavaScript
var numConversion = {'0':'۰', '1':'۱', '2':'۲', '3':'۳', '4':'۴', '5':'۵', '6':'۶', '7':'۷', '8':'۸', '9':'۹'};
$(document).ready(function() {
var grid = $(".myGrid");
var gridContent = grid.contents();
convertText(gridContent);
function convertText(contents) {
contents.each(function() {
if (this.nodeType == 3) {
this.nodeValue =
$("<div/>").html(convert(this.nodeValue)).text();
} else if (this.nodeType == 1) {
convertText($(this).contents());
}
});
}
$(".myGrid").html(grid.html());
function convert(txt) {
var resultTxt = '';
var textChar = '';
for (var i = 0; i < txt.length; i++) {
textChar = txt.charAt(i);
if (numConversion.hasOwnProperty(textChar )) {
resultTxt += numConversion[textChar ];
} else {
resultTxt += textChar;
}
}
return resultTxt;
}
});