0

我有这个上传图片预览代码:

function readURL(input) {
  $.each(input.files,function(i) {
     var reader = new FileReader();
     reader.onload = function (e) {
        var container = $('#preview_drop');
        var image = $('<img>').attr('src', e.target.result).attr('id', 'preimg')
        image.appendTo(container);
        $("#add_photoajax").mCustomScrollbar("update");
     };
     reader.readAsDataURL(input.files[i]);
  });
}

如何在每个预览图像上显示“ x ”标记或delete.png ?

4

1 回答 1

0
 '''
 var container = $('#preview_drop');

 //Create it first
 var x = $('<img>').attr('src', 'delete.png');
 var image = $('<img>').attr('src', e.target.result).attr('id', 'preimg')
 image.appendTo(container);

 //and then append it after/before img
 x.appendTo(container);
 $("#add_photoajax").mCustomScrollbar("update");
 ...
于 2013-05-14T02:27:38.647 回答