James McMahon
James McMahon

Reputation: 49639

How to determine and print jQuery version?

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

Upvotes: 60

Views: 39224

Answers (7)

iewebguy
iewebguy

Reputation: 316

Alert is good, but if you want to actually print the jquery version...

<script>
document.write($.fn.jquery);
</script>

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630409

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 :)

Upvotes: 80

Gabriele Petrioli
Gabriele Petrioli

Reputation: 195992

try

alert($().jquery)

Upvotes: 10

Josiah
Josiah

Reputation: 4854

$().jquery;

This will return a string containing the jQuery version

Upvotes: 12

Faisal
Faisal

Reputation: 4697

$().jquery; // yields the string "1.4.2", for example

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

Upvotes: 11

meder omuraliev
meder omuraliev

Reputation: 186562

alert( $.fn.jquery )

Upvotes: 22

user113716
user113716

Reputation: 322492

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.

Upvotes: 13

Related Questions