So I am an absolute beginner to this and was wondering on how can I add sound (in this case Bell Sound) to an HTML page. The sound needs to play when I scroll down to the section of the page and reach the bell image.
My HTML:
<div class="container">
<img style="max-width: 100%" alt="" src="<?=
enter code herebase_url('assets/bootstrap/')?
>image/ringabox.png">
<audio autoplay="true" >
<source src="<?= base_url('assets/bootstrap/')?>image/ht1.wav" type="wav">
</audio>
</div>
My JS:
var audio = document.getElementsByTagName("audio")[0];
audio.play();
// or with an ID
var audio = document.getElementById("mySoundClip");
audio.play();
Any Help would be appreciated
Thanks