我有以下代码:
function displayImg() {
let fileUpload = document.getElementById("fileUpload").value;
let container document.getElementById("container");
container.innerHTML = `<img src="fileUpload">`
}
<input type = file id = "fileUpload" accept = "image/*">
<button onclick = "displayImg()">Click to show</button>
<div id="container"></div>
我希望用户可以将文件输入到文件输入字段中,并在单击按钮时将其放入动态创建的图像的源中。我该怎么做呢?
饮歌长啸
侃侃尔雅
相关分类