I'm trying to remove the click event listener of some cells in a table but I can't get it to work.
function DofmCalCheck() {
const checkboxDofMElement = document.querySelectorAll('.checkboxDofM');
var cells = document.querySelectorAll('#Dofm_Table td');
cells.forEach(f => f.addEventListener('click', event => {
document.querySelector("#" + f.getAttribute("data-val")).checked = !document.querySelector("#" + f.getAttribute("data-val")).checked;
}));
}
DofmCalCheck();
function MonthDofmBlocks() {
$("#Month_Table td").click(function(event) {
var NoD = parseInt($(this).attr("data-test"));
var Dofm = $("#Dofm_Table td");
for (var i = 0; i < Dofm.length; i++) {
var DofmVal = parseInt(Dofm[i].getAttribute("value")) + 1;
if (DofmVal > NoD) {
Dofm[i].classList.toggle('blocked');
Dofm[i].removeEventListener("click", DofmCalCheck, false);
console.log(Dofm[i]);
}
}
});
}
MonthDofmBlocks();
Where I've added the removeEventListener method, I've set it to true and false but it still doesn't work.