how to loop through <ul><li> using unigue ID

how to loop through <ul><li> using unigue ID

I am trying to loop through my top level nav i.e <ul> <li> and then apply that class name to teh sub level menu of that particular top level. So essentially the clas name on the top <li> wil be applied to its sub level items. Here is my code, which isn't working at the moment - does anyone have any ideas:

$(document).ready(function(){

var pageID = $('body').attr('id');
var uniquePageID

uniquePageID =$("#site-nav ul li",this).attr('id');

$("#site-nav ul li."+uniquePageID+" ul li",this).each(function (i) {
$(this).addClass(uniquePageID);
});

});

Thanks in advance