当前位置:网站首页>JS utils fragmented
JS utils fragmented
2022-07-27 02:43:00 【kilito_ 01】
import $ from "jquery";
function upVal(domArr, i) {
let dom = domArr[i]; // Target element i: Current element subscript , The first few elements
let max = parseFloat($(dom).attr("data-to")); // Target value
let n = parseFloat($(dom).attr("data-n")); // Increase the base
let initVal = parseFloat($(dom).attr("data-init")); // Initial value
commentAdd(dom, initVal, max, n);
};
function commentAdd(dom, initVal, max, n) {
let timer = setInterval(() => { initVal += n; let num = parseFormatNum(initVal); $(dom).text(num); if (initVal >= max) { initVal = parseFormatNum(max); $(dom).text(initVal); clearInterval(timer); } }, 1); }; // Number formatting 【 Partition 3 Numbers add commas 】 function parseFormatNum(number, n) { if (n != 0) { n = (n > 0 && n <= 20) ? n : 2; } number = parseFloat((number + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
let sub_val = number.split(".")[0].split("").reverse();
let sub_xs = number.split(".")[1];
let show_html = "";
for (let i = 0; i < sub_val.length; i++) {
show_html += sub_val[i] + ((i + 1) % 3 == 0 && (i + 1) != sub_val.length ? "," : "");
}
if (n == 0) {
return show_html.split("").reverse().join("");
} else {
return show_html.split("").reverse().join("") + "." + sub_xs;
}
}
export {
upVal, parseFormatNum}
边栏推荐
- 【Redis】快速入门
- go语言慢速入门——包
- As for the pit saved by serialized variables, the data added with indexer cannot be serialized
- Northeast Securities stock online account, is it safe to open an account on your mobile phone
- 【用C语言绘制谢尔宾斯基三角形】
- 通达信开户安全么
- 想要彻底搞的性能优化,得先从底层逻辑开始了解~
- [C language programming] branch structure
- Hcip first day
- 测试工作十年,想对还在迷茫的朋友说:一点要做好个人规划...
猜你喜欢

什么是进程?
![[brother Yang takes you to play with the linear table (III) - two way linked list]](/img/64/5367ff4fb6797565cb1f9e1a8aee4e.png)
[brother Yang takes you to play with the linear table (III) - two way linked list]

聊聊自动化测试的度量指标
![[brother Yang takes you to play with the linear table (4) - chain queue]](/img/b6/ea76e060be73bc14f2166144e7b5e7.png)
[brother Yang takes you to play with the linear table (4) - chain queue]
![[Li Kou] 1859. Sort sentences](/img/0c/f7f698ad0052d07be98e5f888d7da9.png)
[Li Kou] 1859. Sort sentences

中断、信号、系统调用

【用C语言绘制谢尔宾斯基三角形】

多线程的具体使用

The latest JD SMS login + silly girl robot nanny level deployment tutorial (July 24, 2022)
![[C language programming] branch structure](/img/17/f9d5360d8802d29079dcbfcc302003.png)
[C language programming] branch structure
随机推荐
【在Visual Studio 2019中使用SQLite3库实现学生信息管理系统】
[do you know cache - fully understand cache]
White box test case design (my grandfather can understand it)
Redis installation and operation (Linux)
中断、信号、系统调用
Ubuntu基于docker的mysql主从数据库配置
The problem of storing elements in TreeSet collection
I wish you a happy Chinese Valentine's day and invite you to read the source code together
Handsomeforum Learning Forum
Leetcode skimming -- no.238 -- product of arrays other than itself
Constant knowledge explanation of C language
Area optimization of digital chips: detailed explanation of question 1 in the digital direction of the third "Huawei Cup" graduate innovation core competition
excel整行删除,图片一起删除
How many holes have you stepped on in BigDecimal?
【洋哥带你玩转线性表(四)——链式队列】
面试必问 | 一个线程从创建到消亡要经历哪些阶段?
猜拳小程序 基于Object-C 新手上路
Heisei thousand words (Heisei, September 10, 2012) (Shidu Mingzuo) the universe is far away, the Milky way is permanent, the sun and moon are running disorderly, the earth is open, the seasons shift,
TCP three handshakes and four disconnects
N methods of SQL optimization