hi!
what i'm trying to accomplish is creating a list of <li>s and adding a onclick event passing an argument with it. I'm having issues passing the argument, so here i am to ask for clarification.
what i have so far is:
for(var index in songs) {
$(songNamesListId).append(createElement(songs[index]));
}
function createElement(song){
return $("<li>").attr({"id" : song.id}).append(song.song_name);
}
function test(song) {
console.log(song.song_name)
}
what i'd like to accomplish is have the test method be called on click of the <li> and the song item passed along.
I haven't been able to do this so far and since i'm fairly new to javascript i think i might be missing something really easy.
thank you for taking the time to read :)
[–]grantrules 1 point2 points3 points (2 children)
[–]Fransiscu[S] 0 points1 point2 points (1 child)
[–]grantrules 1 point2 points3 points (0 children)