Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$ vs. jQuery: Which should I use?

What is the diffrence between them? Which is better?

like image 800
Diego Avatar asked Dec 24 '10 14:12

Diego


1 Answers

$ is an alias for jQuery, neither is "better" really, jQuery is provided in case something else is using $, like Prototype (or jQuery.noConflict() was called for another reason...).

I prefer $ for brevity because I know it refers to jQuery, if you're unsure (like when writing a plugin) use jQuery for your primary reference, for example:

(function($) {
  //inside here $ means jQuery
})(jQuery);
like image 68
Nick Craver Avatar answered Sep 19 '22 20:09

Nick Craver