I'm trying to add some songs in a playlist , but I can not tell which song was clicked to add.
HTML
<div class='album-musicas'>
<a href='#' id='add-musica-playlist-link' class='addMusicaPlaylistLink'>
<input type='hidden' id='id-musica' value='1' name='dados'>
<input type='hidden' id='nm-musica' value='Musica 1' name='dados'>
<input type='hidden' id='nm-cantor' value='Cantor 1' name='dados'>
<img src='images/button-add-13.png' title='Adicionar à playlist' >
</a>
</div>
<div class='album-musicas'>
<a href='#' id='add-musica-playlist-link' class='addMusicaPlaylistLink'>
<input type='hidden' id='id-musica' value='2' name='dados'>
<input type='hidden' id='nm-musica' value='Musica 2' name='dados'>
<input type='hidden' id='nm-cantor' value='Cantor 2' name='dados'>
<img src='images/button-add-13.png' title='Adicionar à playlist' >
</a>
</div>
JavaScript
$(document).on('click', '#add-musica-playlist-link', function () {
var botoes = document.getElementsByClassName("addMusicaPlaylistLink");
for(var i = 0; i < botoes.length; i++) botoes[i].addEventListener("click", function(e){
var musica_id = e.srcElement.getElementsByTagName("input")[0].value;
alert(musica_id);
});
});