Smarter way of detecting jQuery element.