I am trying to create a audio player in my codes and want to append source to the audio player.
I am not using html5 so it’s a bit different.
I have
var audioPlayer=document.createElement('audio');
audioPlayer.id='audioPlayer';
audioPlayer.className='audioPlayer'
var audioSource=document.createElement('source');
audioSource.src='song.mp3'
$(this).closest('div').append(audioPlayer);
audioPlayer.innerHTML=audioSource; //won't do it......
I want the html like this
<audio id='audioPlayer' class='audioPlayer>
<source src='song.mp3'></source>
</audio>
Thanks for the help!
did you forget to append your audiosource to audioplayer? Audiosource is a child of audioplayer in your example.
try it here jsfiddle