http://api.jquery.com/has/
EDIT - Jay's has better performance, mine was just the first way I thought of it