I think there is something simple I'm missing, but I'm unsure how to fix at this point.
I have a sidebar with a bunch of unordered lists. Each sidebar li item may or may not have a class assigned to it. I need to scan every list item for any with a special class, say: listClass1, listClass2, listClass3. Ignore all others.
My iteration terminates when a list item is reached without any class, i.e. <li>.
The code I have is this:
$('#right li').each(function() {
var classes = $(this).attr('class').split(' ');
var classes = jQuery.grep(classes, function(listClass) {
return ( listClass == 'listClass1' || listClass=='listClass2' || listClass=='listClass3' );
});
for(lc=0; lc<classes.length; lc++) {
$(this).append('<a href="?page='+ classes[lc] +'"><img src="../images/icon/item_'+ classes[lc] +'.gif" /></a>');
}
What am I missing?
}