title: How to iterate through a Bootstrap table and enter in values using JQuery
body: <p>I am trying to iterate through a bootstrap table. I have created if statements so I can get my desired output.</p>
  
  <p>This is my desired output:
  <a href="https://i.stack.imgur.com/btQwN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/btQwN.png" alt="enter image description here"></a></p>
  
  <p>However, so far no value appears in the print cost and paper cost columns but the values appear on the first row if you take out the second row.</p>
  
  <p>My HTML:</p>
  
  <pre><code> &lt;div class="card"&gt;
                  &lt;div class="card-header"&gt;Latest Print Jobs&lt;/div&gt;
  
                  &lt;div class="card-body" style="padding:0px;"&gt;
                      &lt;table class="table"&gt;
                          &lt;thead&gt;
                              &lt;th&gt;#&lt;/th&gt;
                              &lt;th&gt;Employee Name&lt;/th&gt;
                              &lt;th&gt;Job Number&lt;/th&gt;
                              &lt;th&gt;Paper Size&lt;/th&gt;
                              &lt;th&gt;Paper Type&lt;/th&gt;
                              &lt;th&gt;Single or Doubled Sided&lt;/th&gt;
                              &lt;th&gt;Quantity&lt;/th&gt;
                              &lt;th&gt;Colour&lt;/th&gt;
                              &lt;th&gt;Date&lt;/th&gt;
                              &lt;th&gt;Edit&lt;/th&gt;
                              &lt;th&gt;Print Cost&lt;/th&gt;
                              &lt;th&gt;Paper Cost&lt;/th&gt;
                              &lt;th&gt;Total Price&lt;/th&gt;
                          &lt;/thead&gt;
                          &lt;tbody id="main-table"&gt;
  
  
                                        &lt;tr&gt;
                                         &lt;td&gt;14&lt;/td&gt; 
                                          &lt;td&gt;Jafar&lt;/td&gt; 
                                          &lt;td&gt;HCH_003&lt;/td&gt; 
                                         &lt;td&gt;A3&lt;/td&gt; 
                                          &lt;td&gt;Sirio Perla&lt;/td&gt; 
                                           &lt;td&gt;Single&lt;/td&gt; 
                                           &lt;td&gt;9&lt;/td&gt; 
                                          &lt;td&gt;Black &amp; White&lt;/td&gt; 
                                           &lt;td&gt;2018-11-21 16:05:29&lt;/td&gt; 
                                        &lt;td&gt; &lt;a href="http://portal.test/prints/14" class="btn btn-default"&gt;Edit&lt;/a&gt;&lt;/td&gt; 
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;/tr&gt;
  
                                        &lt;tr&gt;
                                         &lt;td&gt;15&lt;/td&gt; 
                                          &lt;td&gt;Jafar&lt;/td&gt; 
                                          &lt;td&gt;HCH_099&lt;/td&gt; 
                                         &lt;td&gt;A4&lt;/td&gt; 
                                          &lt;td&gt;Sirio Perla&lt;/td&gt; 
                                           &lt;td&gt;Single&lt;/td&gt; 
                                           &lt;td&gt;9&lt;/td&gt; 
                                          &lt;td&gt;Black &amp; White&lt;/td&gt; 
                                           &lt;td&gt;2018-11-21 16:20:22&lt;/td&gt; 
                                        &lt;td&gt; &lt;a href="http://portal.test/prints/15" class="btn btn-default"&gt;Edit&lt;/a&gt;&lt;/td&gt; 
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;td&gt;&lt;/td&gt;
                                        &lt;/tr&gt;
  
                          &lt;/tbody&gt;
  
                      &lt;/table&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>My jQuery:</p>
  
  <pre><code>$(document).ready(function() {
    $("tr").each(function() {
      var paper_size = $("#main-table &gt; tr &gt; td:nth-child(4)").text();
      var paper_type = $("#main-table &gt; tr &gt; td:nth-child(5)").text();
      var single_or_double = $("#main-table &gt; tr &gt; td:nth-child(6)").text();
      var colour = $("#main-table &gt; tr &gt; td:nth-child(8)").text();
      var print_cost = $("#main-table &gt; tr &gt; td:nth-child(11)");
      var paper_cost = $("#main-table &gt; tr &gt; td:nth-child(12)");
  
      if (
        paper_type == "Sirio Perla" &amp;&amp;
        paper_size == "A4" &amp;&amp;
        colour == "Black &amp; White"
      ) {
        $(print_cost).text("0.5");
        $(paper_cost).text("0.35");
      } else if (
        paper_type == "Sirio Perla" &amp;&amp;
        paper_size == "A4" &amp;&amp;
        colour == "Colour"
      ) {
        $(print_cost).text("2.5");
        $(paper_cost).text("0.35");
      } else if (
        paper_type == "Sirio Perla" &amp;&amp;
        paper_size == "A3" &amp;&amp;
        colour == "Black &amp; White"
      ) {
        $(print_cost).text("0.1");
        $(paper_cost).text("0.6");
      } else if (
        paper_type == "Sirio Perla" &amp;&amp;
        paper_size == "A3" &amp;&amp;
        colour == "Colour"
      ) {
        $(print_cost).text("0.5");
        $(paper_cost).text("0.6");
      }
    });
  });
  </code></pre>
  
  <p>my codepen to my problem is <a href="https://codepen.io/mrsalami/pen/QJQGjj" rel="nofollow noreferrer">https://codepen.io/mrsalami/pen/QJQGjj</a></p>