traversing one level of dom with nested dom elements.

traversing one level of dom with nested dom elements.

i have been trying to recreate some XUL in html5 using jquery i was working on making the groupbox with caption and i am going to make it so if you add more then one caption it removes all but the first caption as a groupbox can only have one caption. and it works great till you put a groupbox inside another groupbox. 
the nested groupbox elements lose there captions. only the first groupbox will show its caption the right way.
  if($("xul\\:groupbox").length){ $("xul\\:groupbox").each(function(){ $(this).addClass("xul_groupbox ui-corner-all"); $(this).find("xul\\:caption").first().each(function(){ $(this).addClass("xul_groupbox_caption"); }); $(this).find("xul\\:caption").not(":first").each(function(){ $(this).remove(); }); }); }
there can only be one caption for a groupbox and each groupbox should have its own caption. thank you for any help.