JS获取input[file]的值并显示在页面的实现方法
实例如下所示:
$(document).on('change','.photo-box.file',function(){
//alert($(this).val());
functiongetObjectURL(file){
varurl=null;
if(window.createObjectURL!=undefined){//basic
url=window.createObjectURL(file);
}elseif(window.URL!=undefined){//mozilla(firefox)
url=window.URL.createObjectURL(file);
}elseif(window.webkitURL!=undefined){//webkitorchrome
url=window.webkitURL.createObjectURL(file);
}
returnurl;
}
varobjUrl=getObjectURL(this.files[0]);
console.log("objUrl="+objUrl);
varhtml='删除
以上这篇JS获取input[file]的值并显示在页面的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。