Difference between $(‘#tabs a’) and $(‘#tabs’).find(‘a’)

$("#tabs a") evaluates from right to left – which is the native direction of both Sizzle selector engine and querySelectorAll – i.e. first it finds all of the anchor elements in the page and then narrows it down to those under #tabs.

$("#tabs").find("a") evaluates – more intuitively – from left to right, i.e. first it finds #tabs, and then only the anchor elements under it.

Clearly the latter would yield better performance, but it would only be noticeable accumulatively; that is, if you run thousands of queries. Otherwise, the difference is negligible.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)