I like to do something like this:
$.fn.exists = function(){
return this.length > 0 ? this : false;
}
So then you can do something like this:
var firstExistingElement =
$('#iDontExist').exists() || //<-returns false;
$('#iExist').exists() || //<-gets assigned to the variable
$('#iExistAsWell').exists(); //<-never runs
firstExistingElement.doSomething(); //<-executes on #iExist