Immediate play sound on button click in HTML page

后端 未结 5 1122
旧巷少年郎
旧巷少年郎 2021-02-02 17:42

In my HTML page I have 9 images for dialing numbers and one text box that shows the pressed numbers. I want each of those images to immediately play beep sound when users click

5条回答
  •  醉话见心
    2021-02-02 18:15

    This answer https://stackoverflow.com/a/7620930/1459653 by @klaustopher (https://stackoverflow.com/users/767272/klaustopher) helped me. He wrote:

    HTML5 has the new -Tag that can be used to play sound. It even has a pretty simple JavaScript Interface:

    Here's how I implemented his advice so that clicking on the Font Awesome icon "fa-volume-up" (located on the Web page after "mule.") results in "donkey2.mp3" sound playing (note: mp3 doesn't play in all browsers).

    In short, you're treated like a whole person, instead of a rented mule.

提交回复
热议问题