Dynamically add more fields/remove last field in a form

What I want to achieve is to build a form, which contains buttons “add one more field” and “remove last field” that would do exactly this – add a field dynamically to my form or remove the last one. I have done this in Drupal, but am not sure how exactly to achieve this in WordPress.
My basic logic is to use ajax to insert new fields dynamically or remove the last one. Is there something like Form API in WordPress (I tried to search but without success) that will me my task easier to achieve?

Related posts