How do I get the generated HTML ID of a form element?
I know this is two years late but for anyone looking back at this, a way to get the element IDs is to use Drupal Form API's #after_build attribute to add a callback once the form has rendered.

$form['#after_build'] = array('mymodule_afterbuild'); // The callback can be called anything.


Then your function would look something like:

function mymodule_afterbuild(&amp;$form, $form_state) {
  // Get the element ID.
  $id = $form['title']['#id'];
  // Then do something, such as passing it into Drupal settings to access with Javascript.
  drupal_add_js(array('mymodule_js_settings' =&gt; array('title_id' =&gt; $id)), 'setting');
  return $form;
}


Edit to say that the #after_build attribute can be used on individual elements in a form like so:

$form['title']['#after_build'] = array('mymodule_afterbuild');


This actually makes it easier to get the IDs, especially if you're using fieldsets, field collections or other complex field data structures.