news 2026/4/17 12:59:54

数字各位出现次数手动步进演示

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
数字各位出现次数手动步进演示
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>数字计数手动步进方框演示</title><style>body{font-family:Arial,sans-serif;padding:20px;text-align:center;}#container{display:flex;justify-content:center;gap:10px;margin-top:40px;}.digit{width:50px;height:50px;border:2px solid #888;display:flex;flex-direction:column;justify-content:center;align-items:center;transition:background-color 0.3s;font-size:18px;border-radius:6px;position:relative;}.digit.active{background-color:orange;color:white;}.index{position:absolute;top:2px;right:4px;font-size:12px;color:#555;}#controls{margin-top:20px;}#numberInput{width:200px;padding:5px;font-size:16px;}button{padding:5px 15px;font-size:16px;margin-left:10px;cursor:pointer;}</style></head><body><h2>数字各位出现次数手动步进演示(方框版)</h2><p>输入数字,例如:13234</p><inputtype="text"id="numberInput"value="13234"><buttonid="startBtn">开始</button><divid="container"><!-- 数字 0-9 方框 --><divclass="digit"data-num="0"><spanclass="index">0</span><spanclass="count">0</span></div><divclass="digit"data-num="1"><spanclass="index">1</span><spanclass="count">0</span></div><divclass="digit"data-num="2"><spanclass="index">2</span><spanclass="count">0</span></div><divclass="digit"data-num="3"><spanclass="index">3</span><spanclass="count">0</span></div><divclass="digit"data-num="4"><spanclass="index">4</span><spanclass="count">0</span></div><divclass="digit"data-num="5"><spanclass="index">5</span><spanclass="count">0</span></div><divclass="digit"data-num="6"><spanclass="index">6</span><spanclass="count">0</span></div><divclass="digit"data-num="7"><spanclass="index">7</span><spanclass="count">0</span></div><divclass="digit"data-num="8"><spanclass="index">8</span><spanclass="count">0</span></div><divclass="digit"data-num="9"><spanclass="index">9</span><spanclass="count">0</span></div></div><divid="controls"><buttonid="prevBtn">上一步</button><buttonid="nextBtn">下一步</button></div><script>constdigits=document.querySelectorAll('.digit');conststartBtn=document.getElementById('startBtn');constnumberInput=document.getElementById('numberInput');constprevBtn=document.getElementById('prevBtn');constnextBtn=document.getElementById('nextBtn');letcounts=Array(10).fill(0);letsteps=[];// 保存每一步状态letcurrentStep=-1;letnumberStr="";functionresetVisualization(){counts.fill(0);steps=[];currentStep=-1;digits.forEach(d=>{d.classList.remove('active');d.querySelector('.count').innerText=0;});}functionrecordSteps(numStr){counts=Array(10).fill(0);steps=[];for(leti=0;i<numStr.length;i++){constdigit=parseInt(numStr[i]);counts[digit]++;steps.push({current:digit,counts:[...counts]});}}functionrenderStep(stepIndex){if(stepIndex<0||stepIndex>=steps.length)return;conststep=steps[stepIndex];digits.forEach((d,idx)=>{d.classList.remove('active');d.querySelector('.count').innerText=step.counts[idx];});constactiveDigitDiv=document.querySelector(`.digit[data-num='${step.current}']`);if(activeDigitDiv)activeDigitDiv.classList.add('active');currentStep=stepIndex;}startBtn.addEventListener('click',()=>{constinput=numberInput.value.trim();if(!/^\d+$/.test(input)){alert('请输入纯数字!');return;}numberStr=input;resetVisualization();recordSteps(numberStr);renderStep(0);});nextBtn.addEventListener('click',()=>{if(currentStep<steps.length-1){renderStep(currentStep+1);}});prevBtn.addEventListener('click',()=>{if(currentStep>0){renderStep(currentStep-1);}});</script></body></html>
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/18 8:28:35

重新定义空间音频:XMOS一体化方案让你的耳朵成为最强外挂

芯片硬核AI算法支撑50%压力释放100%细节还原游戏HiFi双重体验&#xff0c;且即插即用当消费电子进入“体验为王”的时代&#xff0c;音频技术正成为决定产品竞争力的核心赛道。根据《2025中国影音设备行业白皮书》数据&#xff0c;高保真音响与沉浸式音频设备市场持续扩容&…

作者头像 李华
网站建设 2026/4/18 7:58:56

Java SpringBoot+Vue3+MyBatis 物流管理系统系统源码|前后端分离+MySQL数据库

摘要 随着电子商务的快速发展和全球化贸易的不断深入&#xff0c;物流管理系统在现代商业活动中扮演着至关重要的角色。传统物流管理方式效率低下、信息不透明&#xff0c;难以满足企业对物流效率、成本控制和客户体验的高要求。物流管理系统通过信息化手段优化运输、仓储、配…

作者头像 李华
网站建设 2026/4/15 12:38:25

芯片制造WebUploader怎样在局域网支持大文件分块上传?

咱福州网工仔实锤了&#xff01;最近为了毕设焦头烂额——要搞个能打的大文件管理系统&#xff0c;还要兼容IE8这种“上古浏览器”&#xff08;学校机房那台Win7IE9的老古董&#xff0c;点个按钮都像在玩心跳&#xff09;。找了一圈后端教程&#xff0c;不是“自己悟”就是“付…

作者头像 李华
网站建设 2026/4/17 13:52:04

Desktop Commander MCP

在开发时&#xff0c;如果AI助手不只是个“空谈家”&#xff0c;还能亲手帮你操作数据库、查阅API文档&#xff0c;甚至能生成设计图&#xff0c;那么它就是真正的“搭档”了。Desktop Commander MCP正是这个角色的核心&#xff0c;它像是一个标准的工具间连接器&#xff0c;让…

作者头像 李华