123456class="imgFile"type="file" class="file"
1234567891011121314151617181920212223242526272829303132333435363738394041.imgFile {width:500px;border:1px solid #dbdbdb;display:flow-root}@supports (display:flow-root) {.imgFile {display:flow-root;}}.imgFile label input {display:none}.imgFile label span {width:100px;height:100px;display:inline-block;border:1px solid #999999;margin:16px;position:relative}.imgFile label span:after {width:60%;height:1px;background:#dbdbdb;content:"";display:inline-block;position:absolute;top:50%;left:calc(50% - 30%)}.imgFile label span:before {width:1px;height:60%;background:#dbdbdb;content:"";display:inline-block;position:absolute;left:50%;top:calc(50% - 30%)}.imgFile .imgDiv {
12345678910111213141516171819202122$(".file").change(function() {//获取图片信息var fileLise = $(this)[0].files;var fileLength = fileLise.length;//然后循环 生成html 插入页面上 最后就赋值给imgfor (var i = 0; i < fileLength; i++) {var imgDiv = '<div class="imgDiv"><img id="img' + fileLise[i].name + '"><span><i class="imgRem">×</i></span></div>';$(".imgFile").prepend(imgDiv);var imgName = document.getElementById("img" + fileLise[i].name);if (fileLise && fileLise[i]) {var file = new FileReader();file.readAsDataURL(fileLise[i]);file.onload = function() {console.log(this);imgName.src = this.result}}}});$(".imgFile").on("click", ".imgRem", function() {$(this).parents(".imgDiv").remove();});