Busca Tabela
by Rapha Souza
HTML
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container">
<div class="row">
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
</div>
<div class="row">
<table id="myTable" class="table table-hover">
<thead>
<tr>
<th class="col-md-2">Processo</th>
<th>Cadastros</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<font size="+2"><strong>Suporte Técnico</strong></font>
</td>
<td>
<p><a class="fs-cursor-pointer">Cadastro de Impacto</a></p>
<p><a>Cadastro de Forncedor</a></p>
<p><a>Cadastro de Teste</a></p>
</td>
</tr>
<tr>
<td>
<font size="+2"><strong>Gestão de Demandas</strong></font>
</td>
<td>
<p><a>Cadastro de Impacto</a></p>
<p><a>Cadastro de Coordenadores</a></p>
</td>
</tr>
<tr>
<td>
<font size="+2"><strong>Medição de Contrato</strong></font>
</td>
<td>
<p><a>Cadastro de Teste</a></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
JavaScript
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}