本文介绍了我可以做一个<按钮和GT;不提交表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个形式,用2个按钮
I've got a form, with 2 buttons
<a href="index.html"><button>Cancel changes</button></a>
<button type="submit">Submit</button>
我使用jQuery UI的按钮他们来说,简直像这样
I use jQuery UI's button on them too, simply like this
$('button').button();
然而,第一按钮也提交表单。我本来以为,如果它没有在键入=提交
,不会。
很显然,我能做到这一点。
Obviously I could do this
$('button[type!=submit]').click(function(event) { event.stopPropagation(); });
但是,有没有办法,我可以从提交表单没有JavaScript干预停止后退按钮?
But is there a way I can stop that back button from submitting the form without JavaScript intervention?
说实话,我用了一个按钮,只有这样我就可以用jQuery UI风格吧。我试着打电话按钮()
链接,并如预期没有工作(看起来很丑陋!)。
To be honest, I used a button only so I could style it with jQuery UI. I tried calling button()
on the link and it didn't work as expected (looked quite ugly!).
推荐答案
的<$c$c>type$c$c> 按钮属性
元素的是的提交。
<button type="button">Submit</button>
这篇关于我可以做一个&LT;按钮和GT;不提交表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!