1. 程式人生 > >JQ實現上傳圖片預覽。當然能夠采用插件就用插件。

JQ實現上傳圖片預覽。當然能夠采用插件就用插件。

asd new url src file files data 能夠 func

$( ‘#pic‘ ).change(function () {
var file = $(this)[0].files[0];
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload=function () {
$(‘#mypic‘)[0].src = this.result;
}
})

//一個簡單的js圖片預覽功能,需要有個id 。 2018年10月29日。晚。

JQ實現上傳圖片預覽。當然能夠采用插件就用插件。