So I have 3 tabs set up pretty much exactly like this - https://www.w3schools.com/howto/howto_js_tabs.asp - but the content under each tab is a different video (HTML). My problem is that after changing tabs, the video/audio from the previous tab continues to play - unless I pause the video prior to switching tabs. I've tried a few of the different solutions I've seen for problems similar to this, but still can't find a solution that works on my page.
Here is the HTML I have -
<!-- Tab links -->
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'BEE')" id="defaultOpen">BEE</button>
<button class="tablinks" onclick="openCity(event, 'CRAB')">CRAB</button>
<button class="tablinks" onclick="openCity(event, 'CROW')">CROW</button>
</div>
<!-- Tab content -->
<div id="BEE" class="tabcontent">
<div class="video">
<video width="852" height="480" controls>
<source src="bee.mov" type="video/mp4">
</video>
</div>
</div>
<div id="CRAB" class="tabcontent">
<div class="video">
<video width="852" height="480" controls>
<source src="crab.mov" type="video/mp4">
</video>
</div>
</div>
<div id="CROW" class="tabcontent">
<div class="video">
<video width="852" height="480" controls>
<source src="crow.mov" type="video/mp4">
</video>
</div>
</div>
Here are some of the different solutions I've tried - #1 - The main one I keep coming back to - Pause/stop videos into tabs when I clicked on a tab #2 - How to pause a video when another video's play button is clicked #3 - I've tried to see if there's a way I could switch the space bar to clicking anywhere on this one - https://teamtreehouse.com/community/hi-how-can-i-make-the-video-startstop-by-clicking-anywhere-on-the-video-icon-instead-of-targeting-the-play-button
I'm still very new to JS so any help or suggestions are very much appreciated! Thank you!