0
I have the following code to do a real-time search with jQuery, searching for values within a table:
$(document).ready(function () {
$(".nada").hide();
var $rows = $('.linhas');
$('#search').keyup(function () {
var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
reg = RegExp(val, 'i'),
text;
$rows.show().filter(function () {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text);
}).hide().filter(function () {
$(".nada").show();
});
});
});
But there is a problem: even if you return only one value equal to the one that is typed, it falls into the hide()
and shows the $('.nada').show()
.
How can I fix this?
I don’t know if it helps you or if you can use a jquery lib for this but I use this one: https://mottie.github.io/tablesorter/docs/example-option-theme-bootstrap-v4.html
– Jasar Orion