<input type="file" name="image" class="upfile" size="3" value="" id="demo1"> <img src="/static/images/upload_200_150.jpg" class="layui-upload-img preview-picture" id="demo3" width="80" height="80" onerror="javascript:this.src='/static/images/upload_200_150.jpg';"> <js代码> $(document).ready(function () { $("#demo1").change(function () { var objUrl = pic_ture(this.files[0]); }); }) function pic_ture(pic) { var r = new FileReader(); r.readAsDataURL(pic); r.onload = function (e) { $("#demo3").attr("src", this.result).show(); }; }
主要是js 难看实用
jquery 上传图片预览图片
最新推荐文章于 2021-01-27 02:47:10 发布