Resetting a multi-stage form with jQuery

前端 未结 30 2414
谎友^
谎友^ 2020-11-22 00:58

I have a form with a standard reset button coded thusly:


Trouble i

30条回答
  •  耶瑟儿~
    2020-11-22 01:20

    Modification of the most-voted answer for the $(document).ready() situation:

    $('button[type="reset"]').click(function(e) {
        $form = $(this.form);
        $form.find('input:text, input:password, input:file, select, textarea').val('');
        $form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
        e.preventDefault();
    });
    

提交回复
热议问题