当前位置:网站首页>DOM learning - add + - button
DOM learning - add + - button
2022-04-23 08:25:00 【beinlife】
<button οnclick="calc(this)">-</button>
<span>1</span>
<button οnclick="calc(this)">+</button>
</td>
function calc(btn){
// Find the next span:
//1、 Look up td
var td=btn.parentNode;// Climb up the tree
//2、 stay td Look under span
var span=td.getElementsByTagName("span")[0];// Climb down the tree
//3、 Take out span Number of numbers n
var num=span.innerHTML;
//4、 If btn yes +, be n++, otherwise n--
btn.innerHTML=="+"?num++:num--;
//5、 If n==0, Is changed to 1
num==0&&(num=1);
//6、 take n Put back span in
span.innerHTML=num;
}
版权声明
本文为[beinlife]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230734169084.html
边栏推荐
- 情境领导者-第七章、解决绩效问题
- 通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
- Detailed explanation of ansible automatic operation and maintenance (I) installation and deployment, parameter use, list management, configuration file parameters and user level ansible operating envi
- Idea: export Yapi interface using easyyapi plug-in
- Rearranging log files for leetcode simple question
- One click cleanup of pycharm and jupyter cache files under the project
- Situational leaders - Chapter 7, solving performance problems
- [C语言] 文件操作《一》
- QFileDialog select multiple files or folders
- LeetCode简单题之三除数
猜你喜欢

One click cleanup of pycharm and jupyter cache files under the project

clang 如何产生汇编文件

The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface

监控智能回放是什么,如何使用智能回放查询录像

LeetCode簡單題之計算字符串的數字和
![[learning] audio and video development from scratch (9) -- nuplayer](/img/62/20b0d80088181fb6ff1fe842500c0a.png)
[learning] audio and video development from scratch (9) -- nuplayer

Asan minimalism

SYS_CONNECT_BY_PATH(column,'char') 结合 start with ... connect by prior

关于ORB——SLAM运行中关键帧位置越来越近的异常说明

Listed on the Shenzhen Stock Exchange: the market value is 5.2 billion yuan. Lu is the East and his daughter is American
随机推荐
【路科V0】验证环境2——验证环境组件
2022.4.11-4.17 AI行业周刊(第93期):AI行业的困局
[effective go Chinese translation] part I
Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
vslam PPT
如何保护开源项目免遭供应链攻击-安全设计(1)
[effective go Chinese translation] function
Qt读写XML文件
stm32以及freertos 堆栈解析
多目视觉SLAM
excle加水印
Common regular expressions
mysql查询字符串类型的字段使用数字类型查询时问题
ELK生产实践
情境领导者-第七章、解决绩效问题
欧圣电气深交所上市:市值52亿 陆为东父女为美国籍
Online yaml to XML tool
CSV column extract column extraction
idea:使用easyYapi插件导出yapi接口
jsp页面编码