Question about drupal_add_js I used drupal_add_js() to add a jquery plugin, but there is an error TypeError: $ is undefined at console of firebug. So how should I add the js?
I think you'd find this article in the Drupal documentation relevant and helpful.

The solution is to wrap your custom Javascript code within a closure as shown below:

(function($) {
  // Your Javascript code goes here
})(jQuery);


Javascript files from all Drupal core modules follow this convention. So, you can look them up for reference.

I'm not really sure but either before/after some version of jQuery, the $ was a global alias for the jQuery object itself and could be used directly without the closure but was later removed as it conflicted with other libraries.