Good evening , everyone. I am having some issue trying to add sound effect whenever I click on object. I want to add a sound at the same time as javascript shows the message to user. How do I do that ?
Html code here:
<audio id="music" preload="auto">
<source src="sounds/backgroundMusic.mp3" type="audio/mp3">
<source src="sounds/backgroundMusic3.mp3" type="audio/mp3">
<source src="sounds/sound1.mp3" type="audio/mp3">
</audio>
**Script.js* here:*
if(gameData.opendCardsNumber > 0 && gameData.opendCardsNumber < 10)
{
for(var i = 0; i <= 5; i++)
{
var randomString = Math.floor(Math.random() * messages.length);
var randomStringElement = messages[randomString];
$("#messageBox").html(randomStringElement);
}
}