I've got a form, with 2 buttons(我有一个表格,有两个按钮)
<a href="index.html"><button>Cancel changes</button></a>
<button type="submit">Submit</button>
I use jQuery UI's button on them too, simply like this(我也使用jQuery UI的按钮,就像这样)
$('button').button();
However, the first button also submits the form.(但是,第一个按钮也会提交表单。) I would have thought that if it didn't have the type="submit"
, it wouldn't.(我本以为如果没有type="submit"
,就没有。)
Obviously I could do this(显然我可以做到这一点)
$('button[type!=submit]').click(function(event) { event.stopPropagation(); });
But is there a way I can stop that back button from submitting the form without JavaScript intervention?(但是有没有办法可以在没有JavaScript干预的情况下阻止后退按钮提交表单?)
To be honest, I used a button only so I could style it with jQuery UI.(老实说,我只使用了一个按钮,因此可以使用jQuery UI设置样式。) I tried calling button()
on the link and it didn't work as expected (looked quite ugly!).(我尝试在链接上调用button()
,但未按预期工作(看起来很丑!)。)
ask by alex translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…