jQuery is a JavaScript based library which makes much easier for your web applications using JavaScript. The jQuery is light weight, “write less, do more”, JavaScript library specialized for changing the web page documents on the fly.In this tutorial, we are going to check about JQuery version. You can check the JQuery version by using two ways.
- Using $().jquery method;
- Another one is jQuery.fn.jquery method.
The both ways will display the JQuery version which is used by you in the script.
The latest version of jQuery is jquery-1.11.0. In the all programs we have used this version.You can check jQuery version loaded on the client machine as shown in the following example:
1. Example Using $().jquery
<!DOCTYPE html> <head> <meta charset="ISO-8859-1"> <title>JQuery loaded version</title> </head> <body> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ document.write("jQuery version: " + $().jquery); }); </script> </body> </html>
As shown in the above program, we have used the code inside $(document).ready which is an event which fires up when document is ready. It will run once the page document object model is ready for JavaScript code to execute. The method called $().jquery is used to display the jquery version.
2. Example Using jQuery.fn.jquery
<!DOCTYPE html> <head> <meta charset="ISO-8859-1"> <title>JQuery loaded version</title> </head> <body> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> if(typeof jQuery != 'undefined') { document.write("jQuery version: " + jQuery.fn.jquery); } </script> </body> </html>
As shown in the above program, we have used the code inside if (typeof jQuery!= ‘undefined’) which checks for undefined parameters. It’s needed because ‘undefined’ could be renamed. The method called jQuery.fn.jquery is also used to display the jquery version.
When you run the above example, you would get the following output: