It is easy to manipulate a form element or query an element's attributes with jQuery. Because jQuery's selector function accepts CSS selectors, you can simply select the form element by ID and chain any jQuery method to it to return or manipulate its value or appearance.

When the Drupal Forms API renders a form, it names elements based on their key in the form array. The following element would be rendered with an ID of #edit-code-name:

  $form['code-name'] = array(
    '#type' => 'hidden',
    '#value' => t('James Bond'),
  );

The syntax to select this form element via Javascript with jQuery is:

$('#edit-code-name')

Note that spaces and underscores are filtered into hyphens when rendered, so a form array key of code-name and code_name would be selected per the example above.

So, if you want to use Javascript to display to the user the value of the hidden code name field, you would use the following:

alert($('#edit-code-name').val());

Note: If you're doing dynamic forms this may not work, because on iterative times through the form drupal's form_clean_id() function may generate the form ID as "#formname-1" or "#formname-2". and elements as "#edit-code-name-1", etc. In that case one option is to use a multi-selector like

$(#edit-code-name,#edit-code-name-1,#edit-code-name-2)