Why sometimes I see the prefix jQuery(
in javascript? Is there some differance to write jquery with this prefix jQuery(
or without this prefix?
-
5Do you know what jQuery is in the first place? – BoltClock Apr 11 '14 at 13:20
-
2[jQuery](http://jquery.com/) – Anton Apr 11 '14 at 13:20
-
yes I know. But sometimes I see jquery code with this prefix and sometimes without. Thats why I am asking.. – Ola Apr 11 '14 at 13:22
2 Answers
It is a JavaScript library that simplifies the process of creating scripts that are compatible with a large number of browsers. It also has utility functions that simplify repetitive tasks.
You will also sometimes see $(
which is just an alias for jQuery(
because it's shorter to write. Furthermore, you may see some code that starts with $j(
etc. Those are just other aliases that point to jQuery, but were named differently so that the code would not conflict with other jQuery code running on the page.

- 37,233
- 13
- 109
- 109
-
yes thats what I mean, sometimes I see $( and sometimes jQuery(. So they are the same? – Ola Apr 11 '14 at 13:23
-
1@user1326231 They are the same if you only have jQuery on the page. The reason `jQuery(` is used is because sometimes other JavaScript libraries define their own functions called `$`, but you can be reasonably sure that only jQuery will define a function called `jQuery` – Alex W Apr 11 '14 at 13:29
I think you don't know about jQuery.
jQuery is a lightweight, "write less, do more", JavaScript library.
wherever you have seen this kind code, there they have used some jQuery code. jQuery itself using JavaScript. But code style is quite different.

- 3,335
- 2
- 16
- 27
-
2jQuery... lightweight... pfft, now I have coffee on my monitor... – Niet the Dark Absol Apr 11 '14 at 13:26