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

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

 81.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. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

js在线自定义更改元素CSS工具代码

核心功能使用进度滑块和颜色选择器等在线动态更改CSS特效。可自定义设置间距、背景颜色和模糊等级等。
  实用工具
 7645  0

jquery拾色器赋值背景颜色特效代码

这是一款类似于photoshop的拾色器工具插件,鼠标点击吸取颜色,然后单击右侧即可赋值改变背景颜色。
  实用工具
 2723  0

jquery在线Ping工具

一款基于jquery创建的ping工具插件,输入ping+URL或IP地址,然后在终端中按Enter键,按Control+C断开ping命令。
  实用工具
 3892  0

jquery像素艺术鼠标绘图工具插件

一个轻量级的jQuery像素艺术绘图插件,可在线绘制像素线、形状、文本和图片。
  实用工具
 5889  0

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

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