How can I add and remove form fields using jQuery?


In my application I'm working on the joined table (table between m:n association). There I've a form to insert data in this table. My question now is how I can add and remove dynamically with jQuery form fields as you can see here

Can you give me some examples, tutorials etc.?

Thank you very much!

jQuery has functionality that allows you to add/remove elements from the page, for example the following would remove all <p> tags on the page:


and this will add <p> to any <div> tag


EDIT: The newly created paragraph won't appear on the page though. To place it on the page you would need to add an insertion method.

The two links below should explain them further with some good examples, I hope this helps!

EDIT: As pointed out you may also want to look at Append