I have a simple search function that I use on a table of information, but since I turned the text in the table into editable fields the search function isn't working anymore.
I tried to troubleshoot it in a few different ways, but can't seem to get it working.
Here's what I have got so far:
var $rows = $('.list #data');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
This works just fine on simple plain text tables. Here's a JSFiddle that shows you what I am trying to accomplish:
https://jsfiddle.net/je9mc9jp/8/
//SEARCH
var $rows = $('.list input');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).val().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With