jquery提交form表单时禁止重复提交的方法

前端之家收集整理的这篇文章主要介绍了jquery提交form表单时禁止重复提交的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


$(document).ready(function() {
  $('form').submit(function() {
    if(typeof jQuery.data(this,"disabledOnSubmit") == 'undefined') {
      jQuery.data(this,"disabledOnSubmit",{ submited: true });
      $('input[type=submit],input[type=button]',this).each(function() {
        $(this).attr("disabled","disabled");
      });
      return true;
    }
    else
    {
      return false;
    }
  });
});

猜你在找的Web前端相关文章