Last active
October 6, 2023 05:09
-
-
Save iamrealfarhanbd/66462eb91c1727bd4577d222c3e66fc6 to your computer and use it in GitHub Desktop.
jQuery Code for Formatting Numbers in a Table Column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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