title: Cannot read property 'getElementById' of undefined
body: <p>I have this function to do a filter by jquery, and it is returning this error:</p>
  
  <blockquote>
    <p>Cannot read property 'getElementById' of undefined</p>
  </blockquote>
  
  <pre><code> function VerificaCheck() { 
      var input, filter, table, tr, td, i, filtro;
      input = document.getElementById("busca2");
      filter = input.value.toUpperCase();
      table = document.getElementById("tablepesquisa2");
      tr = table.getElementsByTagName("tr");
      filtro = document.getElementById("filtroPesquisa2").value;
      for (i = 0; i &lt; tr.length; i++) {
          td = tr[i].getElementsByTagName("td")[filtro];
          var tipoProduto = tr[i].getElementById("tipoProduto").value;
          if (td) {
              if (tipoProduto == $('#Produtos').prop("checked")) {
                  tr[i].style.display = "";
              } else {
                  tr[i].style.display = "none";
              }
          }
      }
  }
  </code></pre>
  
  <p>This is the HTML of my table, and the checkbox. If the checkbox is checked it should look for in the table the fields of typeProduct that are true</p>
  
  <pre><code> &lt;div class="form-group"&gt;
                      &lt;div class="col-sm-3"&gt;
                          &lt;select id="filtroPesquisa2" class="form-control"&gt;
                              &lt;option value="0"&gt;Código&lt;/option&gt;
                              &lt;option value="1"&gt;Descrição&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;
                      &lt;div class="col-sm-7"&gt;
                          &lt;input type="text" id="busca2" placeholder="Pesquisa.." onkeyup="myFunction2();" class="form-control" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;div class="table-overflow col-sm-12"&gt;
                          &lt;table class="table table-responsive table-hover" id="tablepesquisa2"&gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;Código&lt;/th&gt;
                                      &lt;th&gt;Nome&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody&gt;
                                  @foreach (var item in Model.Produto)
                                  {
                                  &lt;tr&gt;
                                      &lt;td&gt;@item.Codigo&lt;/td&gt;
                                      &lt;td&gt;@item.nome&lt;/td&gt;
                                      &lt;td align="right"&gt;
                                          &lt;a href="#" onclick="fecha2();CarregaProduto('@item.Codigo');" title="Selecionar"&gt;&lt;i class="fa fa-check-circle fa-lg"&gt;&lt;/i&gt;&lt;/a&gt;&amp;nbsp;
                                      &lt;/td&gt;
                                      &lt;td id="tipoProduto" value="@item.TipoProduto"&gt;@item.TipoProduto&lt;/td&gt;
                                  &lt;/tr&gt;
                                  }
  
                              &lt;/tbody&gt;
                          &lt;/table&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
  &lt;input type="checkbox" asp-for="Produtos" onclick="checkProduto();" name="Produtos" id="Produtos"/&gt;
  </code></pre>