效果预览:
html:
<div class="inputFile">
<input type="file" name="photo" id="photo" "readPic(this)" <#if readonly1?exists && readonly1 == "true">disabled</#if>/> <span>+</span>
<img id="img1" src="" alt="" class="comparison-screen">
<input type="hidden" name="comparePhotoStr" id="comparePhotoStr" />
<i class="close" onclick="closePic(this)"> </i>
</div>
js:
// 读取图片
function readPic(file){
var photoName = $(file).attr("name");
var files = file.files[0];
if(files != '' && files != undefined){
$(file).siblings('i').css('display','block')
if($(file).next().next().attr('src') == ''){
var html = '<div class="inputFile">'+
'<input name=\"'+ photoName +'\" type="file" "readPic(this)" title=" " value="">'+
'<span >+</span>'+
'<img src="" alt="" class="comparison-screen">'+
'<i class="close" "closePic(this)"> </i>'+
'</div>';
$(file).parent('div').after(html);
}
$(file).siblings('img').prop('src',window.URL.c