I'm trying to understand JS referencing.
<a id="ohnoes" href="https://www.kasandbox.org/programming-sounds/rpg/giant-no.mp3">What does Oh Noes say?</a>`
So I reference the above tag here in this function:
var ohnoesEl = document.getElementById("ohnoes");
var onOhNoesClick = function(e) {
e.preventDefault();
var audioEl = document.createElement("audio");
audioEl.src = "https://www.kasandbox.org/programming-sounds/rpg/giant-no.mp3";
audioEl.autoplay = "true";
document.body.appendChild(audioEl);
};
why does this work:
audioEl.src = "https://www.kasandbox.org/programming-sounds/rpg/giant-no.mp3";
but not this:
audioEl.src = ohnoesEl.href;