Many of us might have come across scenarios wherein we wanted to do something based on the version of the jQuery loaded. To be specific I’m talking about scenarios where one might want to know the version of jQuery programmatically and if the version was say 1.3.2 then load some other files too or do something else. Well, I must say that it is a very easy process to identify jQuery’s version, Let’s take a look at how to do it.
You can get to know the version of jQuery loaded by using the following:
alert("jquery version = "+ $.fn.jquery); //or alert("jquery version = "+ jQuery.fn.jquery); //or alert("jquery version = "+ $().jquery);
How to check jQuery version in console?
Checking the version of jQuery through the console of firebug or any other browser-based console is also very easy. You can do it by typing the same code mentioned above in the console.
For e.g :
Go to console and type
$().jquery //Or $.fn.jquery //Or jQuery.fn.jquery
All of the above codes would give you the same result.
How to detect / get jQuery UI version?
Detecting or Checking jQuery UI’s version is also quite simple. However, there was a slight change after version 1.6 was released. Let’s take a look at the code :
/*Use this to check the version number in jQuery UI version 1.6 onwards*/ var jqueryUI_version = $.ui.version; /*Use this to check the version number in jQuery UI prior to version 1.6*/ var jqueryUI_version = $.ui;
So go ahead and share your experience with other readers here. Also do tweet or share this post with your friends.