I am doing some self taught html/js. I am trying to make a simple image uploader, the tutorial I am following gives the following html,
<section id="image" class="button">
<button>Add image</button>
<input type="file" accept="image/*">
</section>
In the CSS I have
section.button input[type="file"] {
display: none;
}
To hide the choose file button. It asks to set up the javascript so that when the add image button is clicked it calls the .click method for the hidden button.
It says this can be done by obtaining a reference to the hidden element. I cannot find anything in the videos supplied which explain how to do this. I have looked on youtube at videos but they all seem to give the hidden input an id such as,
<input type="file" id = "file" accept="image/*">
Is there an error in the supplied html file or is it possible to get obtain a reference to the hidden element without giving it an id?
Thank you