1. Using the jQuery Object
The simplest way to find out the jQuery version is by using the $.fn.jquery or jQuery.fn.jquery property. Both properties return a string containing the version number. Open the browser console (Ctrl + Shift + J for Chrome or Ctrl + Shift + K for Firefox) and type one of the following commands:
This will output the jQuery version number in the console.
2. Checking the jQuery Source File
If you have access to the jQuery source file, you can check the version number directly from the file itself. The version number is usually mentioned in the header comments of the file, whether you are using a minified or non-minified version. Look for a line similar to this:
jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license
In this case, the version number is 3.6.0.
3. Using a Script
You can also create a simple script that will alert the jQuery version being used on a web page. Just copy the following code and paste it in your browser’s address bar:
Press Enter, and an alert box will appear displaying the jQuery version number.
4. Using Browser Developer Tools
Another way to check the jQuery version is by using the browser’s developer tools. Follow these steps:
- Open the developer tools of your browser (press F12 or right-click on the page and select “Inspect”)
- Go to the “Sources” or “Debugger” tab (depending on the browser)
- Navigate to the folder containing the jQuery file you are using
- Click on the jQuery file to open it in the editor
- Check the header comment for the version number (similar to the method mentioned in point #2)
Knowing the jQuery version being used in a project is essential for compatibility and troubleshooting purposes. In this post, we have shown multiple methods to find out the jQuery version, including using the jQuery object, checking the source file, using a script, and using browser developer tools. Remember to always keep your jQuery version up-to-date to take advantage of the latest features and improvements.