Hello,
OK, at this point I have populated a glossary div. When a user clicks on a term this glossary pops-up with all of the terms taken from an XMl file in alphabetical order.
Now what I am trying to do is add the letters 'A', 'B', etc at the beginning of each block of terms beginning with that letter.
Is there an easy way to do this? I was thinking about creating an array with all of the letters of the alphabet, checking the first letter of each term, if it matches, create a new span with that letter, increment the array pointer to look for the next letter.
Is this an efficient way to do it?
This is what I have so far:
Code:
$(glossaryXML).find('item').each(function()
{
if($(this).attr('term').substr(0,1) == 'A')
{
$("#glossaryContent").append("<br /><span class='glossAcro'>" + $(this).attr('term') + "</span><br />");
}
$("#glossaryContent").append("<br /><span class='glossAcro'>" + $(this).attr('term') + "</span>" + "<span class='glossDef'>" + $(this).attr('def') + "</span><br />");
});