I have a table with a fixed left column and I am trying to implement a search function that will show the specific column, not row.
So far, I have only come across a solution that displays the row: How to perform a real time search and filter on a HTML table
However, since my headers are in the column, this method is not very effective.
By the way, I am fairly new to JavaScript, so please bear with me.. :p
You can view my codepen to see what I am attempting to achieve. http://codepen.io/genemiester/pen/qZrpgZ
var $rows = $('#table tr');
$('#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();
});
Is my issue clear? Thank you in advance for any assistance!