I am giving an id of "song-pick" in the following code.
$("#archive").append("<div id=\"song-pick\" data-song=\""+song.rank+"\" class=\"box small back"+counter+"\"><span>"+song.title+"</span></div>");
And trying to print by
$('#song-pick').on("click", function() {
console.log("PICKED");
}
It gets the id well and I can see it on the web as:
<div id="song-pick" data-song="1" class="box small back1"><span>소녀 (A Little Girl) </span></div>
However if I click the element, it doesn't print anything on console. I have no idea why. Tried to fix it by changing to li or ul tags instead of div tag but it didn't work. Need help.