Reputation: 53
I have a bit of javascript which runs like this:
document.getElementById("audio").innerHTML = ("<audio id=\"player\" src=\"data:audio/x-wav;base64,"+encode64(wav)+"\">");
return document.getElementById("player");
I would like to change it to something like this:
audio = document.createElement("audio");
audio.src = "data:audio/x-wav;base64,"+encode64(wav)+"\">";
document.body.appendChild(audio);
return audio;
But, this does not work in the same way. Why is this not essentially equivalent in returning an element with a play
method?
Upvotes: 2
Views: 9302
Reputation: 94339
Extra "\">"
at the end.
audio.src = "data:audio/x-wav;base64,"+encode64(wav)+"\">";
Upvotes: 0
Reputation: 359966
The src
should not have the close tag part:
// ↓↓↓↓↓↓
audio.src = "data:audio/x-wav;base64,"+encode64(wav)+"\">";
Upvotes: 2