371

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.

YakovL
  • 6,451
  • 11
  • 52
  • 82
Jeff
  • 13,536
  • 10
  • 52
  • 97

7 Answers7

548

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

David Hancock
  • 14,591
  • 4
  • 40
  • 44
  • 17
    Note that the version is not always precise to three levels. jQuery 1.4.0 for example prints just `1.4` for `jQuery.fn.jquery` – dtbarne Sep 24 '12 at 14:28
  • 3
    fyi, as of 2.1.4, you can use just `$.fn.jquery`, no need to *call* the `$` function now – jusopi Sep 28 '15 at 15:52
  • 1
    It doesn't work when you load jquery "globaly" via webpack's 3 "ProvidePlugin" feature. – StLia Oct 27 '17 at 13:38
  • @StLia You may need to import the jQuery object... `import jQuery from jquery` – Jeff May 03 '18 at 18:00
40

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

Devy
  • 9,115
  • 7
  • 58
  • 56
14

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

ShankarSangoli
  • 68,720
  • 11
  • 89
  • 123
12
$()['jquery']

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

  • jquery
  • selector
  • prevObject

enter image description here

Abdennour TOUMI
  • 76,783
  • 33
  • 229
  • 231
11

For older versions of jQuery

jQuery().jquery  (or)

jQuery().fn.jquery

For newer versions of jQuery

$().jquery  (or)

$().fn.jquery
Mahendra Jella
  • 5,060
  • 1
  • 31
  • 38
  • 1
    The first syntax `jQuery().jquery` worked for me with a very old version of jQuery (embedded on a legacy project): `1.10.2` – maxxyme Sep 19 '17 at 08:30
3

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

YakovL
  • 6,451
  • 11
  • 52
  • 82
Arun Kumar
  • 39
  • 1
2
console.log( 'You are running jQuery version: ' + $.fn.jquery );
augusto
  • 1,853
  • 16
  • 26
Lakshmana Kumar D
  • 1,947
  • 1
  • 12
  • 10