预览本地图片

    xiaoxiao2021-03-25  188

    $("input[type='file']").change(function(){ $file = $(this); var files = this.files; $.each(files, function(n, item){ if(!item.type.match("image.*")){ return true; } var reader = new FileReader(); reader.onload = function(e){ //获取对应的img 对象 var $img = $file.parent().parent().find("img")[0]; $img.src = this.result; }; reader.readAsDataURL(item); }); });
    转载请注明原文地址: https://ju.6miu.com/read-2548.html

    最新回复(0)