Add a thousands separator to a total with Javascript or jQuery?

前端 未结 12 1891
灰色年华
灰色年华 2020-12-02 16:48

I have a function that sums a column of data in an html table. It does so admirably only I would like to have it put the commas in there that are needed to separate the thou

12条回答
  •  星月不相逢
    2020-12-02 17:27

    Seems like this is ought to be the approved answer...

    Intl.NumberFormat('en-US').format(count)
    

    See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

提交回复
热议问题