.attr('class') is going to return the string assigned to the class attribute. So, given this:
<ul class="menu">
using
$(this).attr('class');
will return the string 'menu'. Prepending the dot to the string allows you to use the variable as the selector string in jQuery. Basically, this:
var attr = '.' + $(this).attr('class');
// now $(attr) === $('.menu');
//otherwise
var attr = $(this).attr('class');
// $(attr) === $('menu');
Without the dot, jQuery will look for a structural element <menu> instead of a structural element with the class 'menu'.
I hope that makes sense. I'm starting to think I haven't had enough coffee today...