https://jsfiddle.net/a6u9zy2h/11/var order = 0;
var images = [];
var imagesPreview = function(input, placeToInsertImagePreview) {
if (input.files) {
var filesAmount = input.files.length;
for (var i = 0; i <= filesAmount; i++) {
var reader = new FileReader();
reader.onload = function(event) {
var image = '<img src="'+ event.target.result +'" width="80" height="80" style="margin-left: 10px; margin-bottom: 8px">';
var imageSortable = '<li id="' + order +'" class="ui-state-default delete-icon"><a><i class="fas fa-times"></i></a>' + image + '</li>';
order ++;
$(placeToInsertImagePreview).append(imageSortable);
};
if (input.files[i]) {
reader.readAsDataURL(input.files[i]);
images.push(input.files[i]);
}
}
console.log(images);
}
};
// $('.ui-state-default').click не работает
$('.ui-state-default').click(function(){
var imageId = ($(this).attr('id'));
alert(imageId);
});
$('#images').on('change', function() {
imagesPreview(this, 'ul.gallery');
});