Resetting a multi-stage form with jQuery

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

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


Trouble i

30条回答
  •  渐次进展
    2020-11-22 01:22

    this worked for me , pyrotex answer didn' reset select fields, took his, here' my edit:

    // Use a whitelist of fields to minimize unintended side effects.
    $(':text, :password, :file', '#myFormId').val('');  
    // De-select any checkboxes, radios and drop-down menus
    $(':input,select option', '#myFormId').removeAttr('checked').removeAttr('selected');
    //this is for selecting the first entry of the select
    $('select option:first', '#myFormId').attr('selected',true);
    

提交回复
热议问题