Home > Enterprise >  Music In JavaScript when on button click
Music In JavaScript when on button click

Time:10-01

When button onclick should work with this mp3 file which I have uploaded to GitHub. it wouldn't work even though I have tried even using the link thru https://voca.ro/1dcHxW3v1oQA

function play() {
  var audio = new Audio('https://voca.ro/1dcHxW3v1oQA
');
 }
<head>
<body>
<button onclick="play()">bwbfw</button>
</body>
</head>

with the code changed it still won't play

CodePudding user response:

Link to the file and trigger play()

function play() {
  var audio = new Audio('https://bobzilla07.github.io/Music_Tap/1979.mp3');
  audio.play();
}
<button onclick=play()>bwbfw</button>

  • Related