HTML
<div style="margin-bottom:20px"id="addImage"></div>
<div style="margin-bottom:20px">
<input id="fb" class="easyui-filebox"name="goods_img" style="width:50%"
data-options="label:'图片上传',prompt:'选择图片(2M以内)',onChange:lookImg "multiple>
</div>
js代码:
<script>
function lookImg(){
var f = $("#fb").next().find('input[type=file]')[0];
if (f.files && f.files[0]){
// 更换图片时清空原图片展示内容
$('#addImage').html('');
for(var i=0;i<f.files.length;i++){
var reader = new FileReader(f.files[i]);
reader.onload = function(e){
//append为在元素中的末尾添加内容
$('#addImage').append("<img src='"+e.target.result+"'width='200px;'/>");
}
reader.readAsDataURL(f.files[i]);
}
}
}
</script>