Reputation: 61
I am working on a site that is outputting price like so: KD45.000 What I would like to do is show the KD and the 3 zeros after the decimal point at half the height of the 45. Thanks Adam
Upvotes: 2
Views: 410
Reputation: 3097
This should be a complete solution for what you're trying to do:
function FormatPrice(price) {
price = price.split('.');
return '<sub>' + (price[0] || 0) + '</sub>.' + (price[1] || '000');
}
Originally: KD45.000
FormatPrice('45.000'): KD45.000
Upvotes: 0
Reputation: 298196
Split the string using .split('.')
into two parts. Output the segments like so:
<sup>KD</sup>{segment1}<sup>.{segment2}</sup>
Upvotes: 1
Reputation: 10305
no javascript just html
KD45.000
Code:
<sup>KD</sup>45<sup>.000</sup>
Upvotes: 2