jQuery提交,我怎么知道按下了什么提交按钮? [英] jQuery submit, how can I know what submit button was pressed?

查看:63
本文介绍了jQuery提交,我怎么知道按下了什么提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajaxSubmit插件发送Ajax表单,但是由于某种原因,该插件没有发送input[type=image]的名称/值.因此,现在我在ajaxSubmit处理该表单之前捕获了Submit事件,我需要知道是否有可能找出按下了哪个按钮?

I'm using ajaxSubmit plugin to send Ajax forms, but for some reason this plugin doesn't send names/values of input[type=image]'s. So now I'm catching the submit event before ajaxSubmit will handle the form and I need to know if it is possible to find out what button was pressed?

推荐答案

$("input .button-example").click(function(){
//do something with $(this) var
});

PS:您是否有jQuery控制$ var?否则,您必须这样做:

PS: do you have jQuery controling the $ var? Otherwise you have to do this:

jQuery.noConflict();
jQuery(document).ready(function(){
    jQuery("input .button-example").click(function(){
    //do something with jQuery(this) var
       alert(jQuery(this));
    });
});

如果您无法控制事件(提交表单)

if you wan't control on event (form submit)

$(document).ready(function(){
    $("#formid").submit(function() {
          alert('Handler for .submit() called.');
          return false;
    });
});

告诉我一些可行的方法;)

tell me something if it worked ;)

这篇关于jQuery提交,我怎么知道按下了什么提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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