我有以下代码: form name="submissions" action="/" onsubmit="window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes')" target="foo" method="post".......input type="submit" id="printbtn" name="printbtn" va
<form name="submissions" action="/" onsubmit="window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes')" target="foo" method="post"> ....... <input type="submit" id="printbtn" name="printbtn" value="Print" /> <input type="submit" id="editbtn" name="editbtn" value="Edit" /> </form>
*已编辑*
window.open只应在单击“打印”按钮时发生.
我想删除onsubmit()事件并使用jQuery执行此操作.我该怎么做?
$('form[name="submissions"]').submit(function(event){ event.preventDefault(); // Do other stuff });
更新:实际上,试试这个……
$(function(){ $('form[name="submissions"]').removeAttr('onsubmit') .submit(function(event){ event.preventDefault(); // This cancels the event... }); // This should fire your window opener... $('#printbtn').click(function(){ window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes'); }) });
应该删除onsubmit,并阻止表单提交…