JSFiddle - React, Tailwind, and code Playground
HTML
<a class="add_photos" id="add_new_photo">Добавить еще фото</a>
<div id="photos_new">
<div class="photo_add"><li class="remove_photo"><a>Удалить</a></li>
<span><input type="file"/><img/></span></div>
</div>
CSS
img {
width:150px;
height:150px;
}
JavaScript
$(document).ready(function () {
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$(input).next('img').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$("body").on("change","#photos_new input",function () {
readURL(this);
});
$("body").on("click", "#add_new_photo", function (e) {
$('#photos_new').prepend('<div class="photo_add"><li class="remove_photo"><a>Удалить</a></li><span><input type="file"/><img/></span><div></div></div>');
});
$("body").on("click", ".remove_photo", function (e) {
$(this).parent('div').remove();
return false;
});
});