I have an onChange event for a checkbox which fires a function that toggles the Visibility of some TRs. My problem is this code only works in firefox. I want it to work for ie8.
function toggleVisibility() {
if ($("#ctl00_PageContent_chkVisibility").is(':checked')) {
$('#ctl00_PageContent_freight_rate_column_chaair tr').each(function(i, val) { // Loop through rows in grid
if (i > 9 & i < 28) {
$('#ctl00_PageContent_freight_rate_column_chaair_r' + i).hide();
};
});
}
else {
$('#ctl00_PageContent_freight_rate_column_chaair tr').each(function(i, val) { // Loop through rows in grid
if (i > 9 & i < 28) {
$('#ctl00_PageContent_freight_rate_column_chaair_r' + i).show();
};
});
};
};
Does anyone know a better way of doing this?
Thanks
I would try using the “starts with” selector instead of trying to concat the id to the index number. Try something like this:
You shouldn’t need to concat the id to the index number because during the loop, you only need to check the index. At that index the hide function will hide the row at said index and thus there is no need to specify the exact id of the row you wish to hide.