如何在jQuery中以特定形式查找提交按钮 [英] How to find the submit button in a specific form in jQuery

查看:84
本文介绍了如何在jQuery中以特定形式查找提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试以特定形式(同一页面上有多种形式)获取提交按钮的jQuery对象.

I try to get jQuery object of a submit button in a specific form (there are several forms on the same page).

我设法获取了表单元素本身.看起来像这样:

I managed to get the form element itself. It looks something like this:

var curForm = curElement.parents("form");

当前元素具有上下文HTMLInputElement.我试图获得表单的相应Submit元素的几种技术:

The current Element has the context HTMLInputElement. The several techniques I tried to get the according submit element of the form:

var curSubmit = curForm.find("input[type='submit']");
var curSubmit = $(curForm).find("input[type='submit']");    
var curSubmit = curForm.find(":submit");
var curSubmit = $(curForm).find(":submit");    
var curSubmit = $(curSubmit, "input[type='submit']");

结果总是一样的(而且很奇怪).我得到的结果是与"curElement"相同的元素.

the result is always the same (and very strange). The result that I get is the same element as "curElement".

那我该如何获得正确的提交按钮?

So how can I get the right submit button?

推荐答案

以下方法应该起作用:

var submit = curElement.closest('form').find(':submit');

这篇关于如何在jQuery中以特定形式查找提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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