Prompt a condition which would compare two words in two columns. For example, if a position (a delay of more than 15 min = agreed, then the counter would add +1 well or on js k ++) if (a delay of less than 15 min and not agreed, then nothing would have happened.)

I currently have a function that counts the values ​​in the column. But here's how to compare two words in different columns I can not think of.

var bol = 0; var min=0; $('td:nth-child(8)').each(function() { if($(this).text() == 'опоздание БОЛЕЕ 15min') { bol++; } if($(this).text() == 'опоздание МЕНЕЕ 15min') { min++; } }); $('span.bol').text('' + bol); $('span.min').text('' + min); 


enter image description here

    1 answer 1

    Use the && operator

     $('tr').each(function (row) { var col1 = $(row).children('td:nth-child(1)').text(); var col2 = $(row).children('td:nth-child(2)').text(); if (col1 === 'опоздание БОЛЕЕ 15min' && col2 === 'согласовано') { k++; } });