解析button和input type=button 的区别

博客指出在form表单里,button按钮会被当作submit提交,不能再单纯当作button使用。若要使用button功能,建议用input type=“button”来实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

很简单,就一句话。

button按钮在form表单的时候会当成submit提交,千万不要再当作button用了,如果想用button就用input type=“button" 来搞。

请帮我完善简易计算器的js代码,我将提供htmlcss代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>计算器1</title> <link rel="stylesheet" href="MyStyle.css" /> <script type="text/javascript" src="index.js"></script> </head> <body> <div class="calculator"> <input class="output" value="" id="output" disabled="disabled"/> <div> <div class="numbers"> <input type="button" value="7" onclick="calculator.numberClick(7)"/> <input type="button" value="8" onclick="calculator.numberClick(8)"/> <input type="button" value="9" onclick="calculator.numberClick(9)"/> <input type="button" value="4" onclick="calculator.numberClick(4)"/> <input type="button" value="5" onclick="calculator.numberClick(5)"/> <input type="button" value="6" onclick="calculator.numberClick(6)"/> <input type="button" value="3" onclick="calculator.numberClick(3)"/> <input type="button" value="2" onclick="calculator.numberClick(2)"/> <input type="button" value="1" onclick="calculator.numberClick(1)"/> <input type="button" value="0" onclick="calculator.numberClick(0)"/> <input type="button" value="AC" onclick="calculator.numberClick(value)"/> <input type="button" value="=" onclick="calculator.numberClick(value)"/> </div> <div class="operators"> <input type="button" value="*" onclick="calculator.numberClick(value)"/> <input type="button" value="-" onclick="calculator.numberClick(value)"/> <input type="button" value="+" onclick="calculator.numberClick(value)"/> <input type="button" value="/" onclick="calculator.numberClick('/')"/>
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值