With JQuery, to check if a selector exists, I do something like :
if ($(selector).length > 0) { ... }
But I suppose it's maybe not the best way because I just want to know if a selector exists, not how many. Is there a way to stop the search at the first occurrence found for optimization reason ?
Thank you!
EDIT: To clarify : I'd like to avoid the "length" method because it checks in all the DOM. I just want to stop when one occurrence is found