I've tried this but it didn't work, plz h !!!
let audioSrcName = ["sam1.mp3","sam2.mp3","sam3.mp3","sam4.mp3","sam5.mp3"];
var randomSong = audioSrcName[Math.floor(Math.random()*audioSrcName.length)];
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', randomSong);
document.getElementById("rand").appendChild(audioElement);
for the html, I just create a div with id ="rand".
Aucun commentaire:
Enregistrer un commentaire