Показать сообщение отдельно
  #3 (permalink)  
Старый 18.11.2019, 09:30
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,072

разделение целой части числа на 3 js
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>
Ответить с цитированием