Can't add js to content creation pages I'm trying to add JS to content create pages using the second function from @kiamlaluno's answer

However, this is not working for me.

I created a module with his folder structure:

add_js
  add_js.info
  add_js.module
  custom.js

add_js.info:

name = Add JS to admin pages
description = Add js to admin pages
core = 7.x


add_js.module:

&lt;?php

    function add_js_init() {
      if (arg(0) == 'admin') {
        $path = drupal_get_path('module', 'add_js');
        drupal_add_js($path . '/custom.js');
      }
    }


custom.js:

jQuery(document).ready(function ($) {
    $("html").addClass("hello");
});


Also tried this .module file:

&lt;?php

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  switch ($form_id) {
    case 'my_form':
      $form['#after_build'][] = 'mymodule_after_build';
      break;
  }
}

function mymodule_after_build($form, &amp;$form_state) {
  $path = drupal_get_path('module', 'mymodule');
  drupal_add_js ("$path/mymodule.js");
  return $form;
}


Although I am pretty inexperienced still, I did remember to enable the module and flush the caches... :D
/**
 *  Implements hook_form_BASE_FORM_ID_alter.
 */
function mymodule_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['#attached']['js'][] = drupal_get_path('module', 'mymodule') . '/js/custom.js';
}


In your case would be:

/**
 *  Implements hook_form_BASE_FORM_ID_alter.
 */
function add_js_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['#attached']['js'][] = drupal_get_path('module', 'add_js') . '/js/custom.js';
}


Note: This will add the JS to all of your content types node edit pages. 



If you need to target a specific content type, all you gotta do is add an if statement, see:

How can I find the form ID of a form?

/**
*  Implements hook_form_BASE_FORM_ID_alter.
*/
  function add_js_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'my_form_id') {
      $form['#attached']['js'][] = drupal_get_path('module', 'add_js') . '/js/custom.js';
    }
  }


and I believe you could alternatively do this, put the my_form_id directly in the hook:

/**
*  Implements hook_form_BASE_FORM_ID_alter.
*/
  function add_js_form_my_form_id_alter(&amp;$form, &amp;$form_state, $form_id) {

      $form['#attached']['js'][] = drupal_get_path('module', 'add_js') . '/js/custom.js';

  }