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

前端 未结 8 1599
盖世英雄少女心
盖世英雄少女心 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:26

    $("input .button-example").click(function(){
    //do something with $(this) 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 ;)

提交回复
热议问题