Assuming this table (actually it could have more columns and rows):
Type |
Color&
-
2021-01-29 12:47
$(function () {
$( "td" ).on( "click", function() {
var type = $(this).text();
$('td:first-child').parent('tr:not(:contains('+type+'))').toggle();
});
});
Type |
Color |
Wheels |
Car |
Red |
4 |
Motorcycle |
Green |
2 |
Bike |
Blue |
2 |
Car |
Blue |
4 |
Bike |
Green |
2 |
Motorcycle |
Red |
2 |
Stores the text from current td, hides tr nodes which do not contain the text.
|