javascript - Add a $ symbol next to number
问题描述
I have this script for tamper-monkey and the script is for amazon I just want to know how to put a $ symbol next to the number thing so it looks like real money is getting into my account.
var oof = document.getElementById("gc-ui-balance-gc-balance-value");
var lastCount = localStorage.getItem("lastCount");
oof.innerHTML = lastCount || "500";
function animateValue(id) {
var obj = document.getElementById(id);
var current = parseInt(obj.innerHTML);
setInterval(function () {
var nextCount = current++;
localStorage.setItem("lastCount", nextCount);
obj.innerHTML = nextCount;
}, 0.1);
}
animateValue('gc-ui-balance-gc-balance-value')
})();
解决方案
Is this what you're looking for?
var oof = document.getElementById("gc-ui-balance-gc-balance-value");
var lastCount = localStorage.getItem("lastCount");
oof.innerText = '$' + lastCount + '.00' || "$500.00";
function animateValue(id) {
var obj = document.getElementById(id);
var current = parseInt(localStorage.getItem("lastCount")) || 500;
setInterval(function () {
var nextCount = current++;
localStorage.setItem("lastCount", nextCount);
obj.innerText = '$' + nextCount + '.00';
}, 0.1);
}
animateValue('gc-ui-balance-gc-balance-value')
})();
推荐阅读
- ios - 如何让相机功能仅显示在一个标签栏项目中?
- python - “主进程退出”错误 Gunicorn systemd 文件
- android - App Auth library Android 在请求令牌时抛出“找不到文件异常”
- kubernetes - Helm Charts 中的秘密管理
- javascript - 在Javascript中,如何在不关闭子窗口的情况下从子窗口刷新父窗口?
- javascript - Twitter + Facebook 从另一个站点自动发布
- java - Java - 从文件中读取结构松散的数据
- r - 循环ggplot分类变量
- r - 从文件夹和子文件夹中复制特定格式的文件并将它们粘贴到新文件夹中
- php - Shell_exec 在 PHP 中返回 NULL