I had a previous question 2 audio sounds and I want to play one HTML5 audio element at a time, which was answered. However, I have 2 more questions:
1) need help interpreting it: What does null from .bind(null,audios[i[) mean? I researched null but still confuse.
External JS:
var audios = document.getElementsByTagName('audio');
for(var i=0; i<audios.length;i++) {
audios[i].onplay = pauseAllAudios.bind(null, audios[i]);
}
function pauseAllAudios(audio){
for(var i=0; i<audios.length;i++)
if(audios[i]!=audio) {
} audios[i].pause();
}
};
2) When I put this in the Html page:
<script type="text/javascript" src="js/audio.js"></script>
before </head>
section, the javascript does not work. If I put it before </body>
section,
the javascript works. Shouldn't javascript work in both areas?