title: Conditional Format A Cell Based on another cell number
body: <p>How do you format a cell based on data from another cell.</p>
  
  <p>This is what I do to format base on the current cell.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  $(document).ready(function() {
    $('table td:nth-child(9)').each(function() {
     var req = $(this).text();
  
          if (req ==  1) {
      $(this).css('backgroundColor', '#009933'); 
       }
          else if(req == 2) {
        $(this).css('backgroundColor', '#ffcc00'); 
       }
  
       else {
        $(this).css('backgroundColor', '#ffffff'); 
       }
      });
      return false;
     });</code></pre>
  </div>
  </div>
  </p>
  
  <p>How would I format Column 5 with this the results from column 9?</p>
  
  <p>If I add .parent() in-between $(this) and .css('backgroundColor</p>
  
  <p>it will change the whole row. </p>
  
  <pre><code>        $(document).ready(function() {
              $('table tr').each(function() {
                  var req = $(this)childNodes[8].text();
  
                  if (req ==  1) {
                      $(this).childNodes[4].css('backgroundColor', '#009933'); 
                  }
                  else if(req == 2) {
                      $(this).childNodes[4].css('backgroundColor', '#ffcc00'); 
                  }
  
                  else {
                      $(this).childNodes[4].css('backgroundColor', '#ffffff'); 
                  }
              });
              return false;
          });
  </code></pre>
  
  <p>@Aryaman Tummalapalli </p>
  
  <p>This didn't work. Trying to format column 5 with the number from column 9</p>