Simple way to clear the value of any input inside a div?

前端 未结 8 1011
谎友^
谎友^ 2020-12-13 07:36

Is there a simple way to iterate over the child elements in an element, say a div, and if they are any sort of input (radio, select, text, hidden...) clear their v

8条回答
  •  半阙折子戏
    2020-12-13 08:30

    Kudos, Haresh! Small addition to uncheck checkboxes. (Use true to check all.)

    $('#myDiv').children().find('input,select').each(function(){
    
    $(this).val('');
    $(this).attr('checked',false);
    
    });
    

提交回复
热议问题