title: I am trying to highlight my table row on sharepoint if it matches anything in an array, why doesn't it work?
body: <p>I have a table on Sharepoint and an array, I tried to compare them and highlight the ones that match but it doesn't work. Please help! The following code is coded in Javascript. I have tried various ways and tweaked accordingly according to my findings all around the web but nothing seems to be able to resolve this issue.</p>
  
  <pre><code>    //gets table
  var oTable = document.getElementById('tablename');
  
  //gets rows of table
  var rowLength = oTable.rows.length;
  
  //loops through rows    
  for (i = 0; i &lt; rowLength; i++){
  
    //gets cells of current row  
     var oCells = oTable.rows.item(i).cells;
  
     //gets amount of cells of current row
     var cellLength = oCells.length;
  
     //loops through each cell in current row
     for(var j = 0; j &lt; cellLength; j++){
  
          // get your cell info here
  
          var cellVal = oCells.item(j).innerHTML;
          console.log(cellVal);
  
          var serverRelativeUrlOfMyFile = "https://Sharepointsite/Blacklist.txt";
          $.ajax({
              url: serverRelativeUrlOfMyFile,
              type: "GET"
          }).done(handler);
          function handler(data){
              //console.log(data);
              var lines = data.split('\n');
              for(var line = 0; line &lt; lines.length; line++)
              {
                  if (cellVal.includes(lines[line])){
                      oCells.item[j].style.background = "red";
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Below's another way that I tried to match my table on Sharepoint with my array. It works partially - Only the last item in the array gets matched when I run through the array properly. I don't really understand so appreciate the people out there who can help! Thanks a lot in advance.</p>
  
  <p>(Additional Information!)
  I create my table on Sharepoint by generating a table using Javascript with the executeQueryAsync function to retrieve data from a Sharepoint list and then producing it out as a viewable HTML table.</p>
  
  <pre><code>        var serverRelativeUrlOfMyFile = "https://Sharepointsite/SoftwaresBlacklist.txt";
  $.ajax({
  url: serverRelativeUrlOfMyFile,
  type: "GET"
  }).done(handler);
  function handler(data){
  //console.log(data);
  var lines = data.split('\n');
      for(var line = 0; line &lt; lines.length; line++){
          //var templines = lines;
          //alert(lines[line]);
  
          $("#tablename tr:contains('" + lines[line] + "')").css("background-color", "red");
      }
  }
  </code></pre>