How to add javascript to drupal 7? I found a responsive menu code here and I want to add it to my Drupal 7 site. I have no experience with JavaScript, but I thought that if i just copy the script into mytheme/js/menu.js, call it in mytheme.info, and add the HTML to a block, I will have the script up and running.

The HTML part works fine, but the JavaScript part isn't working.  

Why doesn't my JavaScript code work?
Well adding JavaScript can be done through drupal_add_js().

You can add the JavaScript code in your template.php file.


Create a cool.js file where you copy the JavaScript code
Put the file in your themes/MYTHEME/js folder
In your template.php file, create a  page preprocess function

function MYTHEME_preprocess_page(&amp;$vars) {
  drupal_add_js(drupal_get_path('theme', 'MYTHEME') . "/js/cool.js", array("preprocess" =&gt; True));    
}

Clear the cache
Load your page and check the page source code to see if cool.js is being loaded; use ctrl+f to see if the file is present there
If the effect is still not coming, then verify the IDs in the HTML are correct