I don’t know your html code, but here is how it will work. The idea is that you keep the original hidden elsewhere.
HTML
<button class="add-form">add form</button>
<form id="main-form">
<div class="form-item row">
<input type="text" name="abc">
</div>
</form>
<div class="stay-hidden original-form-item">
<input type="text" name="abc">
</div>
CSS
.stay-hidden {
display:none;
}
JS
// Add form
jQuery('.add-form').click(function() {
// "Copy" default form
formGroup = jQuery('.original-form-item').clone();
// "Paste" default form
jQuery('#main-form').append('<div class="form-item row">'+ formGroup.html() +'</div>');
});
JSFiddle:
Related Posts:
- Clear form fields with jQuery
- Get a form action/url with jquery
- Twitter Bootstrap Modal Form Submit
- Validate form before submit jquery
- WordPress AJAX File Upload – FrontEnd
- jQuery and AJAX Not working with Select Form Element
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Registration e-mail check with AJAX
- jQuery Validate wp_editor
- Gravity Forms not loading under https, jQuery is not defined
- Gravity list field override and adding javascript [closed]
- How do I setup nested repeatable option fields?
- Accept AJAX call with serialized form data
- Making the wordpress login form a jQuery dropdown
- Cannot prefill hidden Ninja Forms fields
- Frontend Post with JQuery AJAX to Php Issue
- Ajax form submit not working, returns 0
- jQuery will not work on page from snippet or file
- JQuery Counter Limit not working for WP Comment Textarea
- Required radio button does not validate in form, when clicked through Javascript/jQuery
- Converting a working AJAX form to work with WordPress
- jQuery forms & updating info
- How to setup multi-page using jquery?
- Is textarea always accesible throught textarea#content in wordpress dashboard for a specific page?
- Auto next upon clicking image without clicking Next button
- jQuery Validation plugin and Bootstrap 4 CSS classes
- Form validation before submitting
- Is not using admin-ajax to ajax submissions okay?
- $_POST empty in using new php file added to theme
- value not saving in the form when dynamically creating an input
- Customize wp-admin form custom fields
- Auto Select Child categories on Multiple Dropdown – Jquery
- Adding jQuery timepicker to contact form
- jQuery form plugin, submit in the wordpress way
- jQuery Live Form Validation in WordPress
- Contact Form 7 checkbox to add a new class to a div [closed]
- jQuery color picker function on change
- Elementor form – checkboxes validation
- jQuery $(this) keyword
- jQuery Selector: Id Ends With?
- jQuery dialog popup
- jquery loop on Json data using $.each
- Click button copy to clipboard
- $(document).on(“click”… not working?
- How to read data From *.CSV file using javascript?
- jQuery get the image src
- how to define variable in jquery
- Enqueue core jQuery in the footer?
- How to correctly include jquery-ui effects on wordpress
- Check if user is logged in using JQuery
- I want to enqueue a .js file to my child theme
- How to prevent WordPress from loading the jQuery library at the top of the page
- WooCommerce single product edit flexslider settings
- jquery & ajax getting data to php in wordpress
- Including javascript for a shortcode
- adding the full image path to a wordpress javascript file
- Unable to run jQuery script in my template file
- jQuery Plugin to use WordPress functions in AJAX request
- wp_mail very slow
- Unable to uncheck checkbox with jquery in wp admin
- gravity forms jQuery.load into modal [closed]
- jQuery.accordion isn’t a function even when enqueued
- How Can I Add “New” Lazy Load Images To NewsPaper WP Theme? [closed]
- WooCommerce Ajax Cart Update Stopped Working
- WordPress AJAX Load More function duplicating a post
- Plugins loading multiple copies of JQuery
- How to wp_enqueue_script jQuery inside a Plugin
- jQuery accordion plugin won’t work once used in WP
- What is the propre way to include jQuery UI Datepicker’s CSS in plugin?
- How register library to use jquery correct
- How do I translate string inside jQuery script with WPML?
- Using Foundation 5 in WordPress Administration Area
- change order of add_action hooks for jquery to be loaded first
- specifying relative file paths in WP with jQuery requests not working
- Can’t delete the default jQuery in the theme
- WordPress jQuery crash [closed]
- Delete post image attachments with jQuery from the front end
- echo do_shortcode for Contact Form 7 from within dynamically loaded php file
- How to declare/provide file path in JQuery which is emeeded in the WordPress theme
- Name of JQuery technique used on this site [closed]
- Drag and Drop Metadata Menu Order
- need jquery help
- Show More Show Less – Not Working
- How to make JQuery load on top of head tag before everything
- Trying to add google ad onclick to wordpress and Divi buttons and header link
- jQuery Plugin Uncaught TypeError: jQuery(…).slider is not a function
- How to use jQuery plugin
- How to blur the_post_thumbnail() via blur.js (jquery)?
- Passing variable data from external jQuery file to options.php
- Uncaught TypeError: Cannot read property ‘ajax’ of undefined
- :first-child applying to all links [closed]
- Ajax autocomplete based on usercode
- Get selected value with PHP and jQuery
- Add jQuery function to media button
- Why won’t this jQuery work in WordPress?
- Can’t get this jQuery snippet to work with WordPress
- Javascript Loading Effect to URLs
- How to combine jQuery in-place editor with $wpdb->update
- jQuery Add/Remove Classes Not Working
- Can’t seem to check off a category checkbox with jquery?