toFixedNum

功能描述

精确小数点,支持整数,后1位,后2位

依赖的插件

快速使用

    <div class="">请输入小数点位数</div>
    <input id="num" type="text" class="">
    <button onclick="enter()">确定</button>
    <div class="">结果</div>
    <div class="">
      <input id="fixed" class="tofixedNum" type="text" oninput="inputc()">
    </div>
    function enter() {
      serial = document.getElementById('num').value; //小数点后几位数 (必须填写项)
    }

    function inputc() {
      document.querySelector('.tofixedNum').value = $toFixedNum.toFixed(serial, document.querySelector('.tofixedNum')
        .value);
    }

特别说明

输入数字位0,1,2,其他数字无效
是否仍需要帮助? 请保持联络!
最后更新于 2024/04/24