I have a table. I want the user to be able to be able to filter the table by the option they pick in a given drop down. I have it working, but it\'s messy and hard to add new ro
Please find the refactored code "http://jsfiddle.net/5fZv7/3/" here and the code snippet is as below..
html code:
cats
cats 2
dogs
birds
and the javascript code:
$(document).load(function () {
$('#selectFilter').change(function () {
$(".all").hide();
$("." + $(this).find(":selected").attr("id")).show();
});
});
Hopes this helps you to maintain the code easily and efficiently.
- 热议问题