title: Check if a row with specific td exists on a table jquery
body: <p>I want to check if a row that has td with specific title and year.
  Here is my function and the problem is the title2 and year2 are set to undefined.
  How do I get cell values correctly?</p>
  
  <pre><code>var table = $("#mainTable");
          var exist;
          $(table).find("tr").each(function () {
              var title2 = $(this).find("td:nth-child(1)").html();
              var year2 = $(this).find("td:nth-child(2)").html();
              if (title == title2 &amp;&amp; year == year2)
                  exist = true;
  
          });
          return exist;
  </code></pre>
  
  <p>and my table:</p>
  
  <pre><code>&lt;div class="table-responsive"&gt;
      &lt;table class="table table-condensed table-bordered table-striped table-hover" id="mainTable"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th scope="col"&gt;Id&lt;/th&gt;
                  &lt;th scope="col"&gt;Emri&lt;/th&gt;
                  &lt;th scope="col"&gt;Viti&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              @foreach (var subject in Model.Subjects)
              {
                  &lt;tr&gt;
                      &lt;td id="subjectId"&gt;@subject.Id&lt;/td&gt;
                      &lt;td id="subjectTitle"&gt;@subject.Title&lt;/td&gt;
                      &lt;td id="subjectYear"&gt; @subject.Year&lt;/td&gt;
                      &lt;td&gt;
                          &lt;a id="add" class="add" title="Add" data-toggle="tooltip"&gt;&lt;i class="material-icons"&gt;&amp;#xE03B;&lt;/i&gt;&lt;/a&gt;
                          &lt;a id="edit" class="edit" title="Edit" data-toggle="tooltip"&gt;&lt;i class="material-icons"&gt;&amp;#xE254;&lt;/i&gt;&lt;/a&gt;
                          &lt;a id="delete" class="delete" title="Delete" data-toggle="tooltip"&gt;&lt;i class="material-icons"&gt;&amp;#xE872;&lt;/i&gt;&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>