1 回答
TA贡献1993条经验 获得超5个赞
$("#fu_upload").change(function () {
var input = this;
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#Img_preview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
});
$('#btnClear').click(function()
{
$('#fu_upload').val(null);
$('#Img_preview').attr('src', "http://placehold.it/100x100");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<input type='file' id="fu_upload" />
<input type="button" value="clear" id="btnClear"/>
<br/>
<img id="Img_preview" src="http://placehold.it/100x100" alt="your image" />
添加回答
举报