I'm trying to create a simple website with few anime episodes. I have a question about javascript. How can I change video source by clicking on one of my links? I understand, that I have to use event listeners and just change the <source> depending on what link I click, but I'm not that good at programing or googeling.
The video player I'm using is "video js".
If I could get an help I'd be really thankful.
the section of video code:
<div class="sidebar">
<a href="">Episode 1</a>
<a href="">Episode 2</a>
</div>
<div class="main">
<h1>Click the "play button" to start watching!</h1>
<video
id="my_video"
class="video-js"
controls
preload="auto"
width="640"
height="300"
poster="bg2.jpg"
data-setup="{}">
<source src="1-1.mp4" type="video/mp4" />
<source src="1-1.webm" type="video/webm" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
</div>
I would add the javascript file too, but my brain can't write anything useful there :)