html代码:
<button class="btn-elected rt" style="margin-top: 11px;margin-right: 30px;" onclick="saveInfo()">提交</button>
功能需求:
当一个form表单中有多个按钮,且每个按钮的功能不同的时候,点击按钮的时候都会将表单进行提交。
原因解释:
请始终为按钮规定type属性。Internet Explorer 的默认类型是 “button”,而其他浏览器中(包括 W3C 规范)的默认值是 “submit”。
– W3school HTML 标签
意思是,button中type具有三种属性,button,reset,submit,除了Internet Explorer浏览器外,其他浏览器默认的type值都是为"submit",
因此都会提交表单。