views:

95

answers:

6

Is there a jQuery function that returns the version of jQuery that is currently loaded?

+6  A: 

I'm not sure how many versions of jQuery this exists in, but a jQuery object has a jquery property that stores the version.

alert( $().jquery );

Will alert 1.4.2 if you're using that version.

patrick dw
So funny that someone took the time to down vote this answer for no reason. :o) There are some small people around SO these days.
patrick dw
+6  A: 
alert( $.fn.jquery )
meder
+7  A: 

You can use this:

$.fn.jquery
//or if you're using .noConflict():
jQuery.fn.jquery

It's updated automatically when jQuery is built, defined here: http://github.com/jquery/jquery/blob/master/src/core.js#L174

Make sure to use $.fn.property for properties that don't depend on an object, no reason to create an unneeded jquery object with $().property unless you intend to use it :)

Nick Craver
+6  A: 
$().jquery; // yields the string "1.4.2", for example

Source: http://jquery-howto.blogspot.com/2009/02/how-to-check-jquery-version.html

Faisal
That was an impressive quadruple-answer post there, everyone. :3
Faisal
yes +1's all around.
Byron Whitlock
+6  A: 
$().jquery;

This will return a string containing the jQuery version

Josiah
+4  A: 

try

alert($().jquery)
Gaby