How to clear all input fields in a specific div with jQuery?

后端 未结 9 1779
情歌与酒
情歌与酒 2020-12-12 22:11

I am trying to use jQuery to do a simple thing: clear the input fields of a group of input field within a div whenever the form loads, or if the user changes a picklist; but

9条回答
  •  悲&欢浪女
    2020-12-12 22:14

    Couple issues that I see. fetch_results is a class, not an Id and the each function doesn't look right.

    $('.fetch_results:input').each(function() {
          $(this).val('');
    });
    

    Just be sure to remember that if you end up with radios or check buttons, you will have to clear the checked attribute, not the value.

提交回复
热议问题