I have a piece of code that is meant to hide table elements depending on given array. I am running loops to compare innerText of one of the cells and the given array.
However, my if statement is statement is acting weird, once i set the operator to ===
the operation is successful and table rows that match the array are hidden. But i need my if to hide the elements that are not a part of the array, so naturally I set my operator to !==
but once i do it it just executes anyway and of course hides all of the elements in the table.
Any idea why this is happening here is the code:
var td1 = document.querySelectorAll("#course");
var rowss = document.querySelectorAll("#rows");
var diff = _.difference(soretedArray, courseNames1)
console.log(diff);
for(var i = 0 ; i < rowss.length; i++){
for(var j= 0 ; j< diff.length; j++){
if(td1[i].innerText === diff[j]){ // if i set the logic operator to !== it hides all of the elements
console.log(rowss[i]);
rowss[i].style.display= "none";
break;
}
}
}
Aucun commentaire:
Enregistrer un commentaire