小编Liv*_*ini的帖子

Click a button to play sound on Javascript

I would like to make a button play a B-flat scale when clicked. What am I doing wrong?

<!DOCTYPE html>
<html>
<head>
<script>
function PlaySound() {
    alert("hello");
  var bflat = new audio();
  bflat.src = "bflat.mp3";
  document.getElementById(bflat);
  bflat.Play();
}
</script>
</head>
<body>
<audio id="bflat"> </audio>
<button onclick="PlaySound"> B Flat </button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

html ×1

javascript ×1