How to clear a form?

后端 未结 11 638
清歌不尽
清歌不尽 2020-12-03 01:34

For example I have a form like this:

11条回答
  •  不思量自难忘°
    2020-12-03 02:09

    If you're using jQuery, the code is much simpler:

    $('#my-form').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
    

    You can also remove the :hidden from the .not selector if you want to clear hidden fields as well.

提交回复
热议问题