JSFiddle - React, Tailwind, and code Playground
by Gisele Lima
HTML
<form>
<fieldset id="inputs_add">
<label>Nome: <input type="text" name="images[]" /></label><br>
</fieldset>
<label><input type="button" name="add" value="ADD"/></label>
<img src="http://lorempixel.com/50/50/cats" />
<img src="http://lorempixel.com/50/50/nature" />
</form>
JavaScript
var input = '<label>Nome: <input type="text" name="images[]" /> <a href="#" class="remove">X</a></label></br>';
$("input[name='add']").click(function( e ){
$('#inputs_add').append( input );
});
$('#inputs_add').delegate('a','click',function( e ){
e.preventDefault();
$( this ).parent('label').remove();
});
var focused = null;
$("fieldset").delegate("input", "focusin", function() {
focused = $(this);
})
$("img").click(function() {
if (focused.length)
focused.val($(this).attr("src"));
})