title: Using Jquery: Comparing Two Arrays for ANY Match
body: <p>I'm looking for a concise way to compare two arrays for any match. </p>
  
  <p>I am using this comparison to apply a particular style to any table cell that has matching content. One array is a static list of content that should be contained in at least one table cell on the page. The other array is being generated by JQuery, and is the text of all table cells.</p>
  
  <p>The reason why I have to compare content to apply style is that the HTML document will semantically change over time, is being generated by different versions of excel (pretty awful looking code), and this script needs to accommodate that. I know that the content I'm looking to apply the style to in this document will never change, so I need to detect all matches for this content to apply styles to them.</p>
  
  <p>So, the code should be something like (in english):</p>
  
  <p>for each table cell, compare cell text to contents of array. If there is any match, apply this css to the table cell.</p>
  
  <p>This is what I have so far (and I know it's wrong):</p>
  
  <pre><code>$(document).ready(function(){
      $("a.loader").click(function(event){
           event.preventDefault();
           var fileToLoad = $(this).attr("href");
           var fileType = $(this).text();
           var makes = new Array("ACURA","ALFA ROMEO","AMC","ASTON MARTIN","ASUNA","AUDI","BENTLEY","BMW","BRITISH LEYLAND","BUICK","CADILLAC","CHEVROLET","CHRYSLER","CITROEN","COLT","DACIA","DAEWOO","DELOREAN","DODGE","EAGLE","FERRARI","FIAT","FORD","GEO","GMC","HONDA","HUMMER","HYUNDAI","INFINITI","INNOCENTI","ISUZU","JAGUAR","JEEP","KIA","LADA","LAMBORGHINI","LANCIA","LAND ROVER","LEXUS","LINCOLN","LOTUS","M.G.B.","MASERATI","MAYBACH","MAZDA","MERCEDES BENZ","MERCURY","MG","MINI","MITSUBISHI","MORGAN","NISSAN (Datsun)","OLDSMOBILE","PASSPORT","PEUGEOT","PLYMOUTH","PONTIAC","PORSCHE","RANGE ROVER","RENAULT","ROLLS-ROYCE / BENTLEY","SAAB","SATURN","SCION","SHELBY","SKODA","SMART","SUBARU","SUZUKI","TOYOTA","TRIUMPH","VOLKSWAGEN","VOLVO","YUGO","Acura","Alfa Romeo","Amc","Aston Martin","Asuna","Audi","Bentley","Bmw","British Leyland","Buick","Cadillac","Chevrolet","Chrysler","Citroen","Colt","Dacia","Daewoo","Delorean","Dodge","Eagle","Ferrari","Fiat","Ford","Geo","Gmc","Honda","Hummer","Hyundai","Infiniti","Innocenti","Isuzu","Jaguar","Jeep","Kia","Lada","Lamborghini","Lancia","Land Rover","Lexus","Lincoln","Lotus","M.G.B.","Maserati","Maybach","Mazda","Mercedes Benz","Mercury","Mg","Mini","Mitsubishi","Morgan","Nissan (Datsun)","Oldsmobile","Passport","Peugeot","Plymouth","Pontiac","Porsche","Range Rover","Renault","Rolls-Royce / Bentley","Saab","Saturn","Scion","Shelby","Skoda","Smart","Subaru","Suzuki","Toyota","Triumph","Volkswagen","Volvo","Yugo");
           $("div#carApp").html("&lt;img src='images/loadingAnimation.gif' alt='LOADING...' /&gt;");
           $("div#carApp").load(fileToLoad, function(){
               $("#carApp style").children().remove();
               $('#carApp td').removeAttr('style');
               $('#carApp td').removeAttr('class');
               $('#carApp table').removeAttr('class');
               $('#carApp table').removeAttr('style');
               $('#carApp table').removeAttr('width');
               $('#carApp tr').removeAttr('style');
               $('#carApp tr').removeAttr('class');
               $('#carApp col').remove();
               $('#carApp table').width('90%');
               var content = $("#carApp table td");
               jQuery.each(content, function() {
                   var textValue = $(this).text();
                   if (jQuery.inArray(textValue, makes)==true)
                      $(this).css("color","red");
               });
           });
      });
  });
  </code></pre>
  
  <p>Any ideas?</p>