使用jquery使用第二个提交按钮提交表单

时间:2021-12-10 20:34:37

I am having two submit button on a form named 'Save' and 'Delete'. Now I want to explicitly do submit with Delete button. How can I do it? I have tried following:

我在名为“保存”和“删除”的表单上有两个提交按钮。现在我想用删除按钮显式提交。我该怎么做?我试过以下:

$('#myForm').submit();

and

$('#myForm').bind('Delete').submit(); // Delete is value of delete submit button.

but it don't work for delete functionality. Pls help.

但它不适用于删除功能。请帮忙。

2 个解决方案

#1


1  

Something like this:

像这样的东西:

$('delete selector').bind('click', function() { $('#myForm').submit() });

#2


0  

Do you have to use jQuery? Can you not make the delete button a submit type?

你必须使用jQuery吗?你能否将删除按钮设为提交类型?

<input type="submit" name="delete" value="delete"/>

Or:

<button type="submit" name="delete">Delete</button>

#1


1  

Something like this:

像这样的东西:

$('delete selector').bind('click', function() { $('#myForm').submit() });

#2


0  

Do you have to use jQuery? Can you not make the delete button a submit type?

你必须使用jQuery吗?你能否将删除按钮设为提交类型?

<input type="submit" name="delete" value="delete"/>

Or:

<button type="submit" name="delete">Delete</button>