How to detect and print jQuery version?

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

+46
javascript jquery
Jul 13 2018-10-18T00:
source share
7 answers

You can use this:

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

It automatically updates when building jQuery defined here: http://github.com/jquery/jquery/blob/master/src/core.js#L174

Be sure to use $.fn.property for properties that are independent of the object, there is no reason to create an unnecessary jquery object using $().property Property if you are not going to use it :)

+61
Jul 13 '10 at 18:40
source share
 alert( $.fn.jquery ) 
+18
Jul 13 '10 at 18:39
source share
 $().jquery; // yields the string "1.4.2", for example 

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

+11
Jul 13 '10 at 18:40
source share
 $().jquery; 

This will return a string containing the jQuery version

+11
Jul 13 '10 at 18:40
source share

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

 alert( $().jquery ); 

Will warn 1.4.2 if you use this version.

+10
Jul 13 '10 at 18:39
source share

to try

 alert($().jquery) 
+9
Jul 13 '10 at 18:41
source share

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

 <script> document.write($.fn.jquery); </script> 
0
Feb 15 '16 at 16:08
source share



All Articles