I have a collection of videos on my website and I would like them to display with a poster (thumbnail image) initially. The video controls should only appear once the user clicks on the video for the first time. Therefore, when the page is loaded, the controls should be hidden and then become visible upon user interaction.
Here is the JavaScript code snippet I experimented with (included within the header tag):
<script>
document.getElementById("video1").addEventListener("click", setAttribute("controls", "true"));
</script>
Below is the HTML structure I used:
<div class="container1">
<video src="Videos/Film 1.mp4" poster="Thumbnails/Film 1.jpg" class="video1" id="video1">
</video>
</div>