title: Drupal 7 module not loading JavaScript code
body: <p>I am trying to load a JavaScript file for my module. The javascript code should execute and dynamically apply some CSS styling.</p>
  
  <p>However, my jQuery is not having any effect. Plain vanilla JavaScript code works but not my jQuery code.</p>
  
  <p>I am loading my JavaScript with the following code:</p>
  
  <pre><code>drupal_add_js(drupal_get_path('module', 'my_module') .'/js/mycode.js', 'file');
  </code></pre>
  
  <p>I'm applying this code outside of any function but loaded it in <code>hook_node_view</code> when the <code>$view_mode</code> is <strong>full</strong>.</p>
  
  <p>And the following is my javascript:</p>
  
  <pre><code>(function ($) {
  
      alert('RESPONDING!');
  
      $('#page').css('background', 'red')
  
      alert('RESPONDING-2!');
  
  
      jQuery('body').click(
          function () {
              alert('clicked!');
          }
      );
  
  })(jQuery);
  </code></pre>
  
  <p>Nothing <code>$/jQuery</code> tagged works but both alert statements work.</p>