Skip to content

Instantly share code, notes, and snippets.

@olivx
Last active May 11, 2018 19:24
Show Gist options
  • Save olivx/d2d72a1242cc2c44ad72c47534ad3125 to your computer and use it in GitHub Desktop.
Save olivx/d2d72a1242cc2c44ad72c47534ad3125 to your computer and use it in GitHub Desktop.
function filter(element, selector) {
var value = $(element).val().toUpperCase();
$(selector +" li").each(function () {
if ($(this).text().toUpperCase().indexOf(value)> -1) {
$(this).show();
} else {
$(this).hide();
}
});
}
$('.search_client_list').keyup(function(){
filter(this, '#list-client');
})
<script>
function searching() {
var input, filter, table, tr, td, i;
input = document.getElementById("search_box");
filter = input.value.toUpperCase();
table = document.getElementById("tbl");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[1];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
<div class="col-md-6">
<div class="input-group">
<input id="search_box" type="text" name="search_box" value="" class="form-control"
ondragover="" ondragover=" " ondragover="" placeholder="buscar por nome" onkeyup="searching()">
<span class="input-group-btn">
<button type="button" name="button" class="btn btn-primary">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment