first off you don't need to specify the heirarchy in each of your selectors.
$("#cbselectall").on('click', function() {
$(this)
.parents('table') // go to the table element
.find(':checkbox') /* find all checkboxes (note you might need to specifiy
if you have other checkboxes in the table that shouldn't get checked
*/
.prop('checked', $(this).is(':checked')); /* set the checked value to be the value
of the check all checkbox */
})