Search code examples
javascripthtmlcsscurrency

Javascript format currency custom format


I need help with formatting a number. My output is currency format. So $234.22 But I need to make it, so the 22 visually looks like to the power of 22, and the "." no longer shows.

So Dollars = X; Cents = Power to.(vissualy).
X^Cents

Could do some weird logic with cutting up the number, formatting Dollars/cents and make them show like that, but was wandering if theres a library or an easier way.

All search gives me square roots/power to,and other math functions


Solution

  • You need to display the result like this:

    <div class="parent">
        <div id="first" style="display: inline-block;font-size: 20px;">
            $234
        </div>
        <div id="second" style="display: inline-block;padding-left: 5px;vertical-align: super;">
            22
        </div>
    </div>