jQuery problem click function I'm having trouble doing simple stuff in jQuery. What I wanted was to call a function when something was typed in an input field. 

Now I'm just trying this: when you click anywhere on the page to call an alert box like this:

(function ($) {
    $('body').click(function() {
        alert('test');
    });
})(jQuery);


This doesn't work ... . But when I do this:

(function ($) {
    alert('test');
})(jQuery);


I get an alert box when I load the page. My js file is loaded like this:

function xmed_preprocess_page(&amp;$vars) {
    $path = current_path();
    if ($path == 'node/add/product') {
        drupal_add_js(drupal_get_path('theme', 'subtheme') . "/js/add.js", array('weight' =&gt; 1000));
    }
}


The file is loaded correctly. I'm working with jQuery v1.10.2. What could be the problem?
Try this as per drupal standard

(function ($) {
  Drupal.behaviors.exampleModule = {
    attach: function (context, settings) {
      $('body', context).click(function () {
        alert("test");
      });
    }
  };
})(jQuery);


Go through with Managing JavaScript in Drupal 7 for more information