How can I add class to digits "," (comma's) 1,00,000,000. I don't want to add class all digits. I only want to add the class ",". Can anybody help me, please? I am using this code to output the digits
<?php
$re = "/([^\\s>])(?!(?:[^<>]*)?>)/u";
$str = $figure_one;
$subst = "<span class='boxolor'>$1</span>";
$result = preg_replace($re, $subst, number_format($str));
?>
<span class="price-text">£ </span>
<a href="<?php echo $investment_link ; ?>">
<span class="" data-value="<?php echo $result ; ?>"><?php echo $result ; ?></span>
</a>
I am using smof theme options to output the digits. I type 10000000 and it gives me result like this 1,00,000,000 I want to change the color of "," How can I do it? Color should be changed only "," not digits. Thanks in advance
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "<span class='red'>,</span>");
}
pass the value to above function.
Don't make it difficult simply replace your string
<?php
$str = "1,00,000,000";
echo str_replace(",","<span class='red'>,</span>",$str);
?>
demo : https://eval.in/755705
Please check this code.
function AddComma(txt) {
if (txt.value.length % 4 == 3) {
txt.value += ",";
}
}
<input onkeypress="AddComma(this)"/>
</div>