I am rendering values in a table and I have to filter by a field that calls reason, for that I use a script
, the query works, but when deleting the query, the previous values do not return, that is, by deleting the search field the search still persists.
HTML search:
<input type="text" value="" class="form-control pesquisa" style="max-width:200px" />
Js:
$(".pesquisa").keyup(function () {
var texto = $(this).val();
$(".lista").css("display", "grid");
$(".lista").each(function () {
if ($(this).find(".razao").text().toUpperCase().indexOf(texto.toUpperCase()) < 0) {
$(this).css("display", "none");
}
})
})
HTML list:
@if (Model != null)
{
foreach (var item in Model)
{
<tr class="lista" data-codigo="@item.codigo" data-razao="@item.razao">
<td class="col-sm-2 codigo" ><span>
@Html.DisplayFor(modelItem => item.codigo)</span>
</td>
<td class="col-sm-4 razao">
@Html.DisplayFor(modelItem => item.razao)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.cidade)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.estado)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.telefone)
</td>
</tr>
}
}
Can anyone help me?