FYI: You can also use $().closest(selector) to do the same thing as these two lines.