Resetting a multi-stage form with jQuery

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

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


Trouble i

30条回答
  •  心在旅途
    2020-11-22 01:28

    Complementing the accepted answer, if you use SELECT2 plugin, you need to recall select2 script to make changes is all select2 fields:

    function resetForm(formId){
            $('#'+formId).find('input:text, input:password, input:file, select, select2, textarea').val('');
            $('#'+formId).find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
            $('.select2').select2();
        }
    

提交回复
热议问题