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

142
Views
myaudio is not a function

I got two divs with audio files:

        <div class="ru">
        <audio class ="audio-play" src = "hadeWomA.mp3" type="audio/mpeg"></audio>
      </div>
    <div class="ru">
      <audio id ="audio-play" src = "hadeWomB.mp3" type="audio/mpeg"></audio>
    </div>

Im trying to get it to play the one I press on, so i made this:

$(".ru").click(function()
{   
    var myAudio = $(this).children("audio");
    myAudio.play();
});

What am I missing?

When I directily target the audio like this it works

    var myAudio = this.document.getElementById("audio-play");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

play() is not a jQuery method, it’s a vanilla JS method and it works with a single element passed, however jQuery selector returns you a set of a elements. You should pick the first one:

myAudio[0].play();
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!