title: Compare Two Value Of Table Cell To Add Class If The Same
body: <p>I have a problem in comparing two cell value right now. Before I was using <code>onclick</code> function to get specific cell value. Therefore I can easily compare two item but now I need to automatically compare two items and add bootstrap class success if they are the same. The code I am using right now are here below.</p>
  
  <p>JSFIDDLE: <a href="https://jsfiddle.net/aice09/ynh8wfc9/" rel="nofollow noreferrer">https://jsfiddle.net/aice09/ynh8wfc9/</a>
  <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>var tables = document.getElementsByClassName('tb_jobsched');
  var rows = tables[0].getElementsByTagName('tr');
  
  var data = tables.row($(this).parents('tr')).data();
  var poqty = data[5];
  var stock= data[7];
  
  var newpoqty = poqty .replace("PCS", "");
  var newstocks = stock.replace("PCS", "");
  
  if (newpoqty === newstocks) {
    rows[i].classList.add("success");
  } else {
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;table id="tb_jobsched" class="table table-bordered table-hover"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;td&gt;CUSTOMER&lt;/td&gt;
        &lt;td&gt;PO QUANTITY&lt;/td&gt;
        &lt;td&gt;DATE OF DELIVERY&lt;/td&gt;
        &lt;td&gt;STOCKS&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tr&gt;
      &lt;td&gt;CUSTOMER 1&lt;/td&gt;
      &lt;td&gt;2000 PCS&lt;/td&gt;
      &lt;td&gt;2017/06/15&lt;/td&gt;
      &lt;td&gt;5000 PCS&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CUSTOMER 2&lt;/td&gt;
      &lt;td&gt;500 PCS&lt;/td&gt;
      &lt;td&gt;2017/06/15&lt;/td&gt;
      &lt;td&gt;500 PCS&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>