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 ?


    @foreach($songs as $song)
    <audio  class="player" id="player"  src="{{asset('audios/'.$song->song)}}" type="audio/ogg" > 
        <div class="player-control">
            <button id="{{$song->id}}" class="playerbutton play btn btn-outline-info" 
    onclick="playmusic(this)" ><i class="fas fa-play"></i></button>
    <button id="pause" class="playerbutton pause btn btn-outline-info" 
    onclick="pausemusic(this)"><i class="fas fa-pause"></i></button>


var player=document.getElementById("player");
  function playmusic()

  function pausemusic(elem)

41 thoughts on “multi buttons on one javascript function”

Leave a Comment