Search code examples
jquerydescendant

jQuery - Different selectors for descendants?


Can someone please explain how the selectors work for the different descendants? I've looked a bit online but the descriptions I've found so far don't seem to be terribly different.

For example, what's the difference between these three?

$('table tr')
$('table > tr')
$('table + tr')

Solution

    1. Matches all elements with tag name tr that are descendents of table.
    2. Matches all elements with tag name tr that are direct children of table.
    3. Matches all elements tr immediately preceded by sibling table.