The crawl happens in the same order as the elements in the DOM:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>query traversal order</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </head> <body> <ul> <li id="parent1"> <ul> <li id="child1"></li> <li id="child2"></li> </ul> </li> <li id="parent2"> <ul> <li id="child3"></li> <li id="child4"></li> </ul> </li> </ul> <script type="text/javascript"> </script> </body> </html>
This will warn "parent1, child1, child2, parent2, child3, child4";
source share