• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

How To Detect JQuery Version

April 16, 2014 //  by Krishna Srinivasan//  Leave a Comment

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.

  1. Using $().jquery method;
  2. 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.

  • Try It On JSFIDDLE

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.

  • Try It On JSFIDDLE

When you run the above example, you would get the following output:

JQuery Version

Category: jQueryTag: JQuery Basics

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: « Eclipse Tips : Local History Settings in Eclipse
Next Post: PrimeFaces Button Example »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact