What is the difference between the two? What's better?
$ is an alias for jQuery , none of them are "better", jQuery provided if something else using $ , like Prototype (or jQuery.noConflict() , was called for another reason ...).
$
jQuery
jQuery.noConflict()
I prefer $ for short, because I know that this applies to jQuery if you are not sure (e.g. when writing a plugin) use jQuery for your main link, for example:
(function($) { //inside here $ means jQuery })(jQuery);
Functionality is identical if there is no conflict.
Use 'jQuery' instead of '$' to be especially explicit / descriptive, or if you are currently using or suggest using another library that defines '$'.
See also http://api.jquery.com/jQuery.noConflict/
jQuery == $ == window.jQuery == window.$
window.jQuery
window.$
jQuery and $ are defined in the window, and $ can be used if no other library uses it, creating conflicts.
Use either jQuery.noConflict() or closure:
(function ($) { // code with $ here })(jQuery)