I have the following code:
I would use this approach, since ID is a property and not an attribute.
$(function () { var lastchild = $('#div div:last-child').prop('id'); alert(lastchild); });