HTML
<div class="big_box">
<div class="show_img" id="showidcardPh"></div>
<div class="uploader_img">
<input id="idcard_ph" name="file" type="file" capture="camera" accept="image/*" class="manner"/>
</div>
</div>
JS
$("#idcard_ph").change(function () {
var fil = this.files;
for (var i = 0; i < fil.length; i++) {
reads(fil[i]);
}
});
function reads(fil){
var reader = new FileReader();
reader.readAsDataURL(fil);
reader.onload = function(){
var num = document.getElementById("showidcardPh").getElementsByClassName("pic").length;
if (num >= 1){
$(".uploader_img").css({'display': 'none'});
}else if(num <=1){
$(".uploader_img").css({'display': 'block'});
var showPicDiv = document.getElementById("showidcardPh");
showPicDiv.innerHTML += '<div class="pic" style="float:left;margin-bottom:0.6rem;margin-left:0.5rem;border:1px solid #C6C6C6;width:150px;height:130px;text-align:center;display:inline-block;position:relative;z-index:300">'+
'<img class="goodsPico" style="width:90px;height:70px;" src="'+reader.result+'"></img>'+
'<img class="delete_icon" src="../images/delete_icon-18-18.png" Onclick="delPic(this)"></img></div>';
}
};
}
/**
* 功能:删除上传图片显示预览
function delPic(obj){
var nowPic = $(obj).parent().remove();
}
怎么能再加几个上传按钮 并 上传的图片分别预览??