Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Which Javascript function can be used to play more than one audio simultaneously?

I am thinking to make Moodly.site I can add one audio and can make users play it on-click but how to make 1+ audio to be played.I am not sure, can I make it with just Vanilla JS or I need to work with any framework.

Is there any tag in HTML which can allow me to do this or it is solely JS's part?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

var a1 = document.getElementById("a1");
var a2 = document.getElementById("a2");

var b1 = document.getElementById("b1");
var b2 = document.getElementById("b2");

b1.addEventListener("click", function () {
        a1.play();
        
 });
 b2.addEventListener("click", function () {
        a2.play();
 });
<audio id="a1" src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3">
            Your browser does not support the
            <code>audio</code> element.
    </audio>
<audio id="a2" src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3">
            Your browser does not support the
            <code>audio</code> element.
    </audio>
    <button id="b1">1</button>
    <button id="b2">2</button>

Make sure to change the audio files

Edit: added buttons-js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!