$(function() { function get_last_id(parent) { var where = parent; var id = $(parent + " tbody tr:first").attr('id'); alert(id); } get_last_id("#table") });