禁用表单自动提交按钮点击 [英] Disable form auto submit on button click

查看:123
本文介绍了禁用表单自动提交按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我用几个按钮的HTML表单。问题是,不管我点击该按钮,表单将得到提交即使按钮类型提交不。例如按钮的:<按钮和gt;点击做点什么< /按钮> ,导致表单提交

I have a HTML form where I use several buttons. The problem is that no matter which button I click, the form will get submitted even if the button is not of type "submit". e.g. Buttons like :<button>Click to do something</button>, result in form submission.

这是相当痛苦做了一个即preventDefault()这些按钮中的每一个。

It's quite painful to do an e.preventDefault() for each one of these buttons.

我使用jQuery和jQuery UI和网站在HTML5

I use jQuery and jQuery UI and the website is in HTML5.

有没有一种方法来禁用该自动行为?

Is there a way to disable this automatic behavior?

推荐答案

按钮的&LT;按钮&gt;点击做点什么&LT; /按钮&GT; 提交按钮。

设置键入=按钮来改变这种状况。 键入=提交默认情况下(如的由HTML建议指定)。

Set type="button" to change that. type="submit" is the default (as specified by the HTML recommendation).

这篇关于禁用表单自动提交按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆