Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between these two selectors?

Tags:

jquery

$(this).parents('table:first > tbody > tr')

And

$(this).parents('table:first').children('tbody').children('tr')
like image 374
user198729 Avatar asked Dec 08 '09 02:12

user198729


1 Answers

The difference is that the first selector is entirely within the parents call, whereas the second one isn't.

Therefore, the first one looks for all parents of this which match table:first > tbody > tr. (In other words, a tr containing this that is in the first table)

The second one will find the parent of this which matches table:first, then find all of the trs directly within tbodys of that parent. (In other words, all of the trs directly inside the parent table)

like image 128
SLaks Avatar answered Oct 02 '22 19:10

SLaks