How to check jQuery version?

MoreOnFew
Posted underjQuery

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.

TaggedConsoleJavascriptjQueryVersion


MoreOnFew.com – Read tutorials related to JavaScript, jQuery, HTML5, CSS3 and more !

Cover Image for How to check if checkbox is checked in jQuery?

How to check if checkbox is checked in jQuery?

It is very easy to check if a checkbox is checked in jQuery using the .is() or .prop() method of jQuery combined with the ‘:checked’ selector. There are other ways too like checking for the attribute checked value, however, they aren’t very reliable. The easiest and most stable way to check if checkbox is checked … Read more

MoreOnFew
Cover Image for [Solved] Attempted import error: ‘Switch’ is not exported from ‘react-router-dom’

[Solved] Attempted import error: ‘Switch’ is not exported from ‘react-router-dom’

You might be facing an “Attempted import error: ‘Switch’ is not exported from ‘react-router-dom’ ” error if you are using the react-router-dom package version 6. This error is caused due to using the older switch syntax of the react-router-dom. From version 6 onwards, the react-router-dom has replaced “Switch” with “Routes”. Let us take a look … Read more

MoreOnFew