JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<button id="another_field">Add a new field</button>
<div class="cpt_area">
<input placeholder="Type something here..." class="full_width cpt_name" type="text" name="cpt_name[]">
</div>
CSS
input {
padding: 10px
}
JavaScript
// This will copy an input field
$('#another_field').click(function() {
$('.cpt_name:first').clone().prependTo(".cpt_area").val('');
});
// This will generate a data-value attribute
$('input').keyup(function() {
$(this).attr('data-value', $(this).val());
});