html list music code example
Example: how to make a music playlist html
<script>
<!-- Make an array of the song locations in javascript -->
Arr = ['song1.mp3', 'song2.mp3', 'song3.mp3']
<!-- Make the function -->
function func(x) {
document.getElementById('musicPlayer').setAttribute('src', Arr[x])
}
</script>
<audio controls id="musicPlayer" autoplay>
<source src="" type="audio/mp3">
</audio>
<button onclick="func(0)">Song 1</button>
<button onclick="func(1)">Song 2</button>
<button onclick="func(2)">Song 3</button>