Q:

Get specific child of parent list

I have the following code:
sortableList = $("#itemlist");
$(sortableList).click(function(){
   console.log($(this).children().attr('id'));
});

The list contains elements that are direct descendants with ids from id_0 to id_9. I want to get the specific id of the element I am clicking. By running above the above code, the function logs only the id of the first child, regardless of the child I click on.

A:

Assuming #itemlist has div as its children:
$("#itemlist").on("click", "div", function() {
    console.log(this.id);
});

