I have the following code:
is this your wanted behaivour?
$(document).ready(function(){ var lastchild = $("div").last().attr("id") alert(lastchild); });
check out this fiddle for live example
http://jsfiddle.net/sHgbF/