First thing, x.find('tbody > tr')
would find all <tr>
s. You would need to do x.find('> tbody > tr')
, assuming x
is x
from your example.
I ran a test and this with both and this was my finding.
.children(): 3.013ms
>: 0.626ms
so the >
method is faster than the .children()
method. The function calls add up... barely.
Here's my JavaScript for the testing.
var $table = $('#table'), $usingChildren, $usingAngleBracket;
console.time('.children()');
$usingChildren = $table.children('tbody').children('tr');
console.timeEnd('.children()');
console.time('>');
$usingAngleBracket = $table.find('> tbody > tr');
console.timeEnd('>');
console.log( $usingChildren, $usingAngleBracket );