Skip to content
Advertisement

multi buttons on one javascript function

foreach fetch songs from database each audio have button to pause and play all buttons of all songs works with first song only… when i press button of second or third song the first run … any solution ?

blade.php

JavaScript

js.file

JavaScript

Advertisement

Answer

With var player=document.getElementById("player"); you select only one audio element. If you add a unique song id to the buttons and audio tag like this:

JavaScript

Then you may select a bound audio element directly inside the function:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement