Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

when click play sound

<!DOCTYPE html>
<html>
<body>

<audio id="myAudio">
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

<p>Click the buttons to play or pause the audio.</p>

<button onclick="playAudio()" type="button">Play Audio</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button> 

<script>
var x = document.getElementById("myAudio"); 

function playAudio() { 
  x.play(); 
} 

function pauseAudio() { 
  x.pause(); 
} 
</script>

</body>
</html>
Comment

click play sound

<!doctype html>
<html>
  <head>
    <title>Audio</title>
  </head>
  <body>

    <script>
      function play() {
        var audio = document.getElementById("audio");
        audio.play();
      }
    </script>

    <input type="button" value="PLAY" onclick="play()">
    <audio id="audio" src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3"></audio>

  </body>
</html>
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: regular expression url 
Javascript :: get buildspec.yml file for react app 
Javascript :: javascript table show only first n rows 
Javascript :: jquery check if input is empty on keyup 
Javascript :: react fetch request with content type x-www-form-urlencoded 
Javascript :: how to link prototypes in js using call method 
Javascript :: super in javascript 
Javascript :: javascript math 
Javascript :: vue js qr code scanner 
Javascript :: strapi blank dashboard page 
Javascript :: random between min and max 
Javascript :: send embed with webhook in JS 
Javascript :: p5.js radians 
Javascript :: regular expression javascript 
Javascript :: orderbychild firebase react 
Javascript :: js addeventlistener input searcb mobile 
Javascript :: javascript online compiler 
Javascript :: request-promise-native error RequestError: Error: unable to verify the first certificate 
Javascript :: window close function in javascript 
Javascript :: react write into json file 
Javascript :: forward and reverse loop one by one js 
Javascript :: create index mongodb 
Javascript :: change a css class in javascript 
Javascript :: js backtick new line 
Javascript :: export csv single javascript 
Javascript :: javascript sleep 1 minute 
Javascript :: javascript .target 
Javascript :: Using An Array As A Parameter Of A Function 
Javascript :: example of call by value and call by reference in javascript 
Javascript :: console 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =