Skip to content

Instantly share code, notes, and snippets.

@iamrealfarhanbd
Last active October 6, 2023 05:09
Show Gist options
  • Save iamrealfarhanbd/66462eb91c1727bd4577d222c3e66fc6 to your computer and use it in GitHub Desktop.
Save iamrealfarhanbd/66462eb91c1727bd4577d222c3e66fc6 to your computer and use it in GitHub Desktop.
jQuery Code for Formatting Numbers in a Table Column
// you can replace "_amount" with you column key column_key
$('tbody .ninja_clmn_nm_amount').each(function() {
// Get the cell value and parse it as an integer
var cellValue = parseInt($(this).text().trim());
// Check if the value is 1000 or more
if (cellValue >= 1000) {
// If it's 1000 or more, format the value with commas
$(this).text(cellValue.toLocaleString());
} else {
// If it's less than 1000, keep the value as it is
$(this).text(cellValue);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment