nyshangal nyshangal - 6 months ago 30
HTML Question

how can we make a digit after decimal appear like a superscript in javascript?

how can we make a digit after decimal appear like a superscript in java.

here is the example

I have the price say suppose
$14.98, is there a way that i can print those .98 as supercript.

thank you

this is how i am getting price value
<%=price.getBasePrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString()%>

Answer
$('.price').each(function () {
    var $this = $(this),
        $val = $this.text(),
        dec_pos = $val.indexOf('.');
    $this.html($val.substring(0, dec_pos) + '<sup>' + $val.substring(dec_pos + 1) + '</sup>');
});

http://jsfiddle.net/tD9PW/