If I get a recordset from a mySQL database of 10 names, I can use jquery to filter those by first letter. However, if I had a link on a page for every letter of the alphabet, and wanted to grey out the ones that did not have any “results”, how would I do this?
Here is how I am currently filtering the results:
$(document).ready(function() {
function filterResults(letter){
$('p').hide();
$('p').filter(function() {
return $(this).text().charAt(0).toUpperCase() === letter;
}).show();
};
filterResults('A');
$('a').on('click',function(){
var letter = $(this).html();
filterResults(letter);
});
});
Fiddle of the example is here:
http://jsfiddle.net/livinzlife/8UE6m/
What I would like is for all letters unaccounted for to be grey. I have no idea how to select those that are unaccounted for though.
http://jsfiddle.net/zLxKU/