I got this code:
$(document).ready(function () {
$('tr.DataDark input[type=checkbox], tr.DataLight input[type=checkbox]').click(function () {
$(this).closest('tr').toggleClass('Selected');
});
$('tr.DataDark input[type=checkbox]:checked, tr.DataLight input[type=checkbox]:checked').each(function () {
$(this).closest('tr').addClass('Selected');
});
});
Can it be shorter written?
Thanks for suggestions.
Maybe this? Not exactly shorter, but possibly simpler.
To make it shorter you could forego the
checkBoxesvariable and chain thefilter().closest().addClass()calls directly toon("click").