Get the jQuery Version

By  on  

Many JavaScript frameworks provide a version property on their main object, providing a quick bit of important information about the framework.  The main jQuery object doesn't provide this property, however, so developers need to do a bit more work to get that version information.  Here's how to get the jQuery version number for a given jQuery script!

The jQuery JavaScript

The jQuery version lives within jQuery.fn:

var v = jQuery.fn.jquery;

/*
You may also use:

var v = jQuery().jquery; // "1.4.2"
*/

The jquery property of the jQuery.fn object provides the version number as a string.  Not as easy as .version access, but provides the jQuery version nonetheless!

Recent Features

  • By
    Chris Coyier’s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

Incredible Demos

  • By
    Form Element AJAX Spinner Attachment Using MooTools

    Many times you'll see a form dynamically change available values based on the value of a form field. For example, a "State" field will change based on which Country a user selects. What annoys me about these forms is that they'll often do an...

  • By
    CSS Gradients

    With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements.  CSS gradients are another step in that direction.  Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!