Get jQuery version from inspecting the jQuery object
Asked Answered
C

7

382

Is there a way to find out what version of jQuery is being used by inspecting the jQuery object? jQuery is dynamically getting added to my page and I cannot see any reference to it in my markup. If I inspect it in my browser's console, it's there.

Chorography answered 28/7, 2011 at 23:35 Comment(0)
N
558

You can use either $().jquery; or $.fn.jquery which will return a string containing the version number, e.g. 1.6.2.

Network answered 28/7, 2011 at 23:40 Comment(4)
Note that the version is not always precise to three levels. jQuery 1.4.0 for example prints just 1.4 for jQuery.fn.jqueryDihydric
fyi, as of 2.1.4, you can use just $.fn.jquery, no need to call the $ function nowCanonry
It doesn't work when you load jquery "globaly" via webpack's 3 "ProvidePlugin" feature.Pheon
@Pheon You may need to import the jQuery object... import jQuery from jqueryChorography
G
41

FYI, for the cases where your page is loading with other javascript libraries like mootools that are conflicting with the $ symbol, you can use jQuery instead.

For instance, jQuery.fn.jquery or jQuery().jquery would work just fine:

screen shot for checking jQuery version

Grani answered 3/12, 2012 at 22:19 Comment(0)
L
14

$().jquery will give you its version as a string.

Lushy answered 28/7, 2011 at 23:43 Comment(2)
$ is a reference to the jQuery function and $() references a jQuery instance (just in case anyone wonders why)Stokehold
Easy to copy/paste... :)Church
K
13

For older versions of jQuery

jQuery().jquery  (or)

jQuery().fn.jquery

For newer versions of jQuery

$().jquery  (or)

$().fn.jquery
Keelykeen answered 26/2, 2015 at 7:13 Comment(1)
The first syntax jQuery().jquery worked for me with a very old version of jQuery (embedded on a legacy project): 1.10.2Plenish
D
12
$()['jquery']

Invoke console.log($()) and take note about jquery object fields :

  • jquery
  • selector
  • prevObject

enter image description here

Donaldson answered 22/5, 2013 at 20:41 Comment(0)
S
4

You can get the version of the jquery by simply printing object.jquery, the object can be any object created by you using $.

For example: if you have created a <div> element as following

var divObj = $("div");

then by printing divObj.jquery will show you the version like 1.7.1

Basically divObj inherits all the property of $() or jQuery() i.e if you try to print jQuery.fn.jquery will also print the same version like 1.7.1

Septima answered 1/4, 2012 at 3:28 Comment(0)
S
2
console.log( 'You are running jQuery version: ' + $.fn.jquery );
Subspecies answered 17/6, 2013 at 13:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.