ajaxst,
<!DOCTYPE html>
<html>
<head>
<script>
function numberWithCommas(str) {
return (+str).toFixed(2).replace(/(\d+)(\.\d+)?/g, function (c, b, a) {
return b.replace(/(\d)(?=(\d{3})+$)/g, "$1 ") + a
});
}
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".threewords").forEach(
function(elem) {
elem.textContent = numberWithCommas(elem.textContent);
})
});
</script>
</head>
<body>
<div class="threewords">123123</div>
<div class="threewords">9000.99</div>
</body>
</html>