Assigning classes to visible li elements only, and changing dynamically

Assigning classes to visible li elements only, and changing dynamically

I'm putting together an events calendar at  http://609vibe.com/events-calendar/

Each event is a li item, and I use jQuery to assign the class "no-left-m" (no left margin) to li:nth-child(3n+1) for CSS layout purposes.

I've also added the ability to show only events in certain categories. Unfortunately, the initial jQuery assigns the classes to li items from the DOM, and doesn't take into account the show/hide. This means that when I show only a single category, the margins are off.

I've tried the following;

$j('#events-master-list li:visible:nth-child(3n+1) .addClass('no-left-m');

But with no joy.

Any ideas on how I can assign my classes dynamically to nth-child(3n+1) of *visible* items only?