I was looking at some code from a tutorial for creating a carousel menu and noticed parent child selectors without the parent. Never seen this before, and confused to what it is
$('> div', this)
The this
is important. It's a context parameter that makes the query equal to
$(this).children('div');
See the documentation for $() for more information; it specifically mentions this:
Internally, selector context is implemented with the .find() method, so
$('span', this)
is equivalent to$(this).find('span')
.
$(this).find('> div')
means "the div
s that are children of this
, which is equal to $(this).children('div')
.