Hello all,
With the following code I’m trying to mark values, that occur in the table more than once, red.
I searched the internet and found some solutions that mark only the duplicates and not the first occurrence.
The code below however does not work (does not mark duplicates)
Thwe code goes as follows:
first it loops through the table and pushes all values in an array
In the second loop it checks if the value already exists in the array and if so, it should be marked red.
Any ideas?
function findDuplicatesInTable(){
var column = 1;
var arrDup = [];
$('#excel_table td:nth-child(' + column + ')').each(function() {
arrDup.push(this.innerHTML);
});
$('#excel_table td:nth-child(' + column + ')').each(function() {
var numOccurences = $.grep(arrDup, function (elem){
return elem === this.innerHTML;
}).length;
if(numOccurences > 1){
$(this).css('color', "red")
}
});
}