So I want to set <img src="">
attribute using JavaScript, but the source would be a input element value.
<img src="" id="userImage" onclick="changeImage()">
<input type="file" id="imageInput">
function changeImage() {
var userImage = document.getElementById("imageInput").value;
document.getElementById("userImage").src = userImage;
}
Note: <input type="image">
don't work for me as it doesn't show window to select image.
When I open console, it shows
Failed to load resource:
net::ERR_UNKNOWN_URL_SCHEME