0

There is such a HTML code:

<div class="addMore"></div>
<div class="adProfInner">
   <div class="formAdd"><form></form></div>
</div>

By clicking on the addMore need to reset the form to the container formAdd

Here is that code did not work:

$(this).next('.adProfInner').find('form').trigger('reset');
Balmus
  • 11
  • 5
  • possible duplicate of [How to reset a form programmatically?](http://stackoverflow.com/questions/12313312/how-to-reset-a-form-programmatically) – JJJ Dec 02 '14 at 17:59

2 Answers2

2

Can try using reset(). Example:

$('.addMore').click(function(){
    $(this).next('.adProfInner').find('form')[0].reset();
});
MH2K9
  • 11,951
  • 7
  • 32
  • 49
  • Does not work, only input text was cleared. But select lists does not with a attribute `selected` – Balmus Dec 02 '14 at 18:28
0

You can also use this method.

$('.addMore').click(function(){
    $(this).next('.adProfInner').find('form').reset();
});

or

<div class="addMore"></div>
<div class="adProfInner">
   <div class="formAdd"><form id='my_form'></form></div>
</div>

script here

 $('.addMore').click(function(){
        $('#my_form').reset();
    });
Muhammed Shuhaib
  • 314
  • 6
  • 20
  • If use `$('#my_form').reset();` I get error: `Uncaught TypeError: undefined is not a function` – Balmus Dec 02 '14 at 18:40