JQuery DOM selector workaround and efficiency

What is the standard search direction for multipart selectors jQuery?

eg. happening

$('#myTable tr.selected');

Is the first search for #myTableand then the search tr.selectedis only inside this table?

Or the first search for everyone tr.selectedon the page and the second search checking each of the parent nodes?

+3
source share
2 answers

You should watch this John Resig talk on this subject . He says that, contrary to what you expect, selector engines will search tr.selectedand then see if the ancestor matches #myTable.

+2
source

#myTable, tr.selected

myTable, , 'tr' selected

+1

Source: https://habr.com/ru/post/1786206/


All Articles