-2

Hi i saw selector that is 'parent > child', but didn't see selector that start at '>' What does it means?

below this code..

    $cb.on('change', function(e){
      e.preventDefault();
      $('> tbody > tr > td:first-child > input:checkbox', $bTable).prop('checked', this.checked);
    });
dev_jongtae
  • 41
  • 1
  • 6

3 Answers3

2

In this specific case the second parameter of the selector function gives the Context. So the selector selects the first level child tbody from the Context, which is in the $bTable variable

user3154108
  • 1,264
  • 13
  • 23
2

$('> tbody > tr > td:first-child > input:checkbox', $bTable) this translates into this:

$($bTable).find('> tbody > tr > td:first-child > input:checkbox')

The $bTable variable is the context in this case for jQuery selector $().

Check this link for more info: https://stackoverflow.com/a/3497900/9748618

freedomn-m
  • 27,664
  • 8
  • 35
  • 57
navidanindya
  • 158
  • 1
  • 6
  • 1
    I originally upvoted, but then you added a link to a duplicate. The question should be marked/flagged as a duplicate if there's already an answer elsewhere in SO. – freedomn-m Jun 04 '18 at 09:48
1

it selects only first-level descendants. FYI Official Documentation

Wils
  • 1,178
  • 8
  • 24
  • This doesn't seem to answer the question; OP already knows purpose of child selector but is asking what (if any) significance it has when it is missing the 'parent'. – TZHX Jun 04 '18 at 08:56