No. Sorry, you have to use the .length property. This is a side effect of Javascript that evaluates all objects as true, and obviously the jQuery selector is a functionally object. However, the resulting syntax is not so bad:
$(function(){ var element = $('.findElement'), otherElement = $('.findSomeOtherElement'), lastAttempt = $('.lastAttempt'); var elegance = (element.length && element) || (otherElement.length && otherElement) || (lastAttempt.length && lastAttempt); elegance.css('border','1px solid green'); });
Demo
source share