Customizing menu html How do you set an id for the menu's root &lt;ul&gt; tag?

I know about the module "Menu Attributes" but that doesn't let me add an ID to the root &lt;ul&gt;, or at least I do not know how.

Also, I've seen a solution which uses theme_menu_tree() and a regex check, but that's just too hacky for my taste.
In D7 default theme bartik, you can see the main menu is rendered using a theme hook links__system_main_menu:

 &lt;div id="main-menu" class="navigation"&gt;
    &lt;?php print theme('links__system_main_menu', array(
      'links' =&gt; $main_menu,
      'attributes' =&gt; array(
        'id' =&gt; 'main-menu-links',
        'class' =&gt; array('links', 'clearfix'),
      ),
      'heading' =&gt; array(
        'text' =&gt; t('Main menu'),
        'level' =&gt; 'h2',
        'class' =&gt; array('element-invisible'),
      ),
    )); ?&gt;
  &lt;/div&gt; &lt;!-- /#main-menu --&gt;


links__system_main_menu is a theme hook pattern of the form [base hook]__[context]. 
When links are themed with theme('links__system_main_menu', $vars), theme() will search for and use theme_links__system_main_menu() if it has been defined. If not, it will use theme_links().

Drupal will use MYTHEME_links__system_main_menu(), if you define it in your theme.
Thus, you could implement the hook_links__system_main_menu as follows. Probably you will do that in the template.php file in your theme folder.:

function mytheme_links__system_main_menu($variables) {
  $html = "&lt;div&gt;\n";
  $html .= "  &lt;ul id=\"your_id\"&gt;\n";  
  foreach ($variables['links'] as $key =&gt; $link) {
    $html .= "&lt;li&gt;".l($link['title'], $link['path'], $link)."&lt;/li&gt;";
  }
  $html .= "  &lt;/ul&gt;\n";
  $html .= "&lt;/div&gt;\n";

  return $html;
}


This will override the links__system_main_menu theme and customize HTML output for the main menu.

[Edit]

If you are looking for the quickest way, you just need to tweak your page.tpl.php by adding an extra wrapper to the menu ul.
For example, in the Bartik theme,

  &lt;div id="main-menu" class="navigation"&gt;
    &lt;div id="your-id"&gt;
    &lt;?php print theme('links__system_main_menu', array(
      'links' =&gt; $main_menu,
      'attributes' =&gt; array(
        'id' =&gt; 'main-menu-links',
        'class' =&gt; array('links', 'clearfix'),
      ),
      'heading' =&gt; array(
        'text' =&gt; t('Main menu'),
        'level' =&gt; 'h2',
        'class' =&gt; array('element-invisible'),
      ),
    )); ?&gt;
    &lt;/div&gt;
  &lt;/div&gt; &lt;!-- /#main-menu --&gt;


Then, you can access it using #your-id ul{ } in CSS or $('#your-id ul') in JS.
But, the above code is just for example, you should not hack the core themes or modules.
I assume you have your own theme.