no matter what you selection is the function $()
always returns a jQuery object so that cant be used to test. The best way yet (if not the only) is to use the size()
function or the native length property as explained above.
if ( $('selector').size() ) {...}