<div class="xiaJiaUpload"> <input type="file" class="type-file file-input" name="picFile" id="five"/> <span class="file-span"> <img src="images/upload.jpg" alt="" id="imgfive" data_src=""/> </span> </div>
$(".xiaJiaUpload input").change(function() { var files = this.files; var that = $(this); var strHtml = ""; var tmpFile = files[0]; var reader = new FileReader(); //每循环一次都要重新new一个FileReader实例 reader.readAsDataURL(tmpFile); reader.onload = function(e) { that.next().find("img").get(0).src = e.target.result; }; });