原生js可视化进度记录每日耗水量在线统计工具

所属分类: 网页特效-实用工具    2023-12-09 12:11:57

 91.2K  1  查看评论 (0)
原生js可视化进度记录每日耗水量在线统计工具 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

原生js可视化进度记录每日耗水量在线统计工具(共3个文件)

    • index.html

使用方法

const smallCups = document.querySelectorAll(".small-cup");
const litres = document.querySelector(".litres");
const percentage = document.querySelector(".percentage");
const remained = document.querySelector(".remained");
const todaysGoalText = document.querySelector("h5");
const resetButton = document.querySelector(".reset-button");

let totalWater = 3;
let percentValue = 0;

smallCups.forEach((cup, index) => {
	cup.addEventListener("click", () => updateBigCup(index));
});

resetButton.addEventListener("click", () => resetLogs());

function updateBigCup(index) {
	const logValue = parseInt(smallCups[index].innerHTML);

	totalWater -= logValue / 1000;
	litres.innerText = totalWater + " L";

	percentValue += (logValue / 3000) * 100;
	percentage.innerText = percentValue.toFixed(1) + " %";

	if (percentValue >= 99) {
		litres.innerText = "0 L";
		percentage.innerText = "100 %";
		todaysGoalText.innerText = "You have achieved your daily goal. Keep it up !";
	}
}

function resetLogs() {
	totalWater = 3;
	percentValue = 0;
	litres.innerText = "3.00 L";
	percentage.innerText = "0 %";
	todaysGoalText.innerText = `Today's goal is : 3 litres`;
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

javascript温度转换器在线工具

一个基于原生js的在线温度转换器工具,可轻松得将华氏温度转换为摄氏温度。你可在select列表中选择摄氏度或华氏度,input文本框中输入温度值,并立即转换。
  实用工具
 4834  0

jquery简易版在线记事本工具插件

一款简单的在线记事本应用程序,可记录笔记或书写短文等,可保存下来供日后使用。
  实用工具
 2763  0

基于html2canvas将html导出为图片或PDF文件

这是一款超级实用的转换工具插件,可将html内容导出为PDF文件。
  实用工具
 2592  0

jquery电影院在线选预订选座选票特效插件

一款在线选择座位特效插件,可自定义座位布局,支持设定购买人数,可选择连坐位置,。
  实用工具
 1744  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论