JSFiddle - React, Tailwind, and code Playground
HTML
<p id="friendlist">
<input type="text" name="friend_name[]" class="friendid">
<input type="text" name="friend_email[]" class="friendid"/></p>
<div id="addanother">add another friend</div>
<input type="submit" name="submit" />
JavaScript
$(function() {
var nextIndex = 2;
$("#addanother").click(function() {
var html = '<br />';
html += '<input type="text" name="friend_name[]" class="friendid" />'
html += '<input type="text" name="friend_email[]" class="friendid" />';
$("#friendlist").append($(html));
nextIndex++;
});
});