Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Javascript Audio Play on click


JavaScript

function playAudio(url) {
  new Audio(url).play();
}

HTML

<img src="image.png" onclick="playAudio('mysound.mp3')">

Supported in most modern browsers and easy to embed into HTML elements.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Javascript #Audio #Play #click
ADD COMMENT
Topic
Name
5+4 =