I would like to change the audio element I inserted with another audio element.
I checked the solution at: Create Audio element dynamically in Javascript, and I don't understand why my code isn't working.
In HTML I have:
<audio id="sound" src="shush1.mp3" controls>
Your Browser Does Not Support the Audio Feature
</audio>
and in babySounds.js I have:
var sound = document.createElement('audio');
sound.src = "Shush2.mp3";
sound.controls = "controls";
document.getElementById("sound").appendChild(sound);
<audio>, but I would assume it's not working because you are nesting the tags with yourappendChild(), such that you have<audio id="sound" src="shush1.mp3" controls\> Your Browser Does Not Support the Audio Feature <audio src="Shush2.mp3" controls="controls"></audio></audio\>. You probably want to replace the original instead.replaceWithlike thisdocument.getElementById("sound").replaceWith(sound)?