时间:2021-07-01 10:21:17 帮助过:7人阅读
实例如下所示:
$(document).on('change', '.photo-box .file', function () {
//alert($(this).val());
function getObjectURL(file) {
var url = null;
if (window.createObjectURL != undefined) { // basic
url = window.createObjectURL(file);
} else if (window.URL != undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
return url;
}
var objUrl = getObjectURL(this.files[0]);
console.log("objUrl = " + objUrl);
var html = '<p class="photo-box"><img src="' + objUrl + '" alt=""><p class="photo-btn"><p>删除</p></p></p>';
$(this).parent().parent().append(html);
})上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
vue结合Echarts实现点击高亮效果的示例
vue实现a标签点击高亮方法
Vue-路由导航菜单栏的高亮设置方法
以上就是JS如何获取input[file]的值并显示在页面的方法?(图文教程)的详细内容,更多请关注Gxl网其它相关文章!