Home jquery Cleaning the shape jQuery

Cleaning the shape jQuery

Author

Date

Category

There are two forms on the site.
There is also a clean button.
Clicking Cleans the contents of the Inputs.

$ document.on ('click', '.js-clearapplication', function (E) {
  E.PreventDefault ();
  var form = $ ('. js-form');
  form.find ('INPUT, TEXTAREA'). Val ('');
});

One of the forms in the modeling, which by default has Display: None

here then cleaning and does not work.
I understand that due to the fact that when loading the page, this form is not in DOM

How to solve the problem?

Example of marking

& lt; form class = "header__application-form js-applicationform js-form" action = "" & gt;
            & lt; div & gt;
              & lt; p & gt; Your name & lt; / p & gt;
              & lt; Input Type = "Text" Placeholder = "Your name" & gt;
              & lt; p & gt; Telephone & lt; / p & gt;
              & lt; Input Type = "Tel" Placeholder = "+ 7 ____ ____ __ __" & gt;
            & lt; / div & gt;
            & lt; div & gt;
              & lt; p & gt; Comment & lt; / p & gt;
              & lt; textarea rows = "5" Placeholder = "Please describe more
About your holiday. "& gt; & lt; / textarea & gt;
            & lt; / div & gt;
            & lt; div & gt;
              & lt; p & gt; mail & lt; / p & gt;
              & lt; Input Type = "Email" Placeholder = "@ Inbox.ru" & gt;
            & lt; / div & gt;
            & lt; div & gt;
              & lt; Button class = "btn_black" & gt; send & lt; / button & gt;
              & lt;! - & lt; button class = "reset" type = "reset" & gt; erase & lt; / button & gt; - & gt;
              & lt; a class = "js-clearapplication" href = "#" & gt; erase & lt; / a & gt;
            & lt; / div & gt;
          & lt; / form & gt;

I tried to add Button [Type = RESET]
Something it does not clean the form (
The main problem is that clicking on the button is not processed.

i.e. it does not reach to clean the form


Answer 1

You can simply use the standard button for cleaning the & LT; Input Type = “Reset” / & GT;

& lt; form & gt;
& lt; h2 & gt; form number 1 & lt; / h2 & gt;
& lt; Input Type = "Text" / & gt;
& lt; Input Type = "Reset" / & gt;
& lt; / form & gt;
& lt; Form & gt;
& lt; h2 & gt; form number 2 & lt; / h2 & gt;
& lt; Input Type = "Text" / & gt;
& lt; Input Type = "Reset" / & gt;
& lt; / form & gt; 

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions