Why does JQuery have dollar signs everywhere?

jquery

Solution

`$` is just a shortcut for `jQuery`. The idea is that everything is done with the one global symbol (since the global namespaces is ridiculously crowded), `jQuery`, but you can use `$` (because it's shorter) if you like:

// These are the same barring your using noConflict (more below)
var divs = $("div");       // Find all divs
var divs = jQuery("div");  // Also find all divs, because
console.log($ === jQuery); // "true"

If you don't want to use the alias, you don't have to. And if you want `$` to not be an alias for `jQuery`, you can use `noConflict` and the library will restore `$` to whatever it was before jQuery took it over. (Useful if you also use Prototype or MooTools.)

Problem

I am working on a project with quite a lot of JQuery in it. The JQuery has a lot of $ signs everywhere, for example ``` $(document).ready(function () { $('input[type=file]').wl_File({ url: '/Admin/PolicyInventory/UploadDocuments', onFileError: function (error, fileobj) { $.msg('file is not allowed: ' + fileobj.name, { header: error.msg + ' Error ', live: 10000 }); } }); ... ``` My question is, what does this dollar sign mean? Why is it used all over the place and how do I understand and interpret it? It reminds me of the scary days of when I was learning Scheme at University and had to put brackets everywhere without knowing why I was doing it.

Original source

Related problems