jQuery submit, how can I know what submit button was pressed?

前端 未结 8 1568
盖世英雄少女心
盖世英雄少女心 2020-12-14 23:43

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 su

8条回答
  •  春和景丽
    2020-12-15 00:16

    This is what I am using (slight variation on the others, using mouseup and keyup events instead of focus):

    var submitButton = undefined;
    $('#your-form-id').find(':submit').live('mouseup keyup',function(){
        submitButton  = $(this);
    });
    $('#your-form-id').submit(function() {
        console.log(submitButton.attr('name'));
    });
    

提交回复
热议问题