I don't know precisely how the selector parsing works, I think the differents methods are very quick but in some cases of selection, when secleting by ID, I am afraid that the parser will try to find each item even it found one already. For example I am looking for $('#myDiv'), it is by ID so if I respect HTML, I assume that I should have only one element with this ID, and so I am looking only for ONE element, no more. So often I do :
- var e = $('#myDiv').first();
to be sure working only with one element, but this will look for EVERY item anyway and then return me the first.
I am thinking about something like :
- $.fn.find = function(selector, limit){
- if(isNaN(limit)){// when limit is not required
- call current jquery find(selector) for keeping current parsing speed
- }else{
- parse until result limit is reached
- }
- }