2 decimal places in Javascript/jQuery

I always forget how to format a number as 2 decimal places in Javascript/jQuery, its extremely simple, just use the unmemorable toFixed() function - refer below is an example

$("#total"+row_number).html($total,toFixed(2));

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP, ReactJS, Tableau, AWS RedShift and Matillion ETL

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Name Notify me of replies by email.