jQuery jquery Property
The jquery property in jQuery objects holds the version number of the jQuery library currently in use. It is a simple string value that helps developers check which version is loaded on a page.
What is the jquery Property?
- Returns the jQuery version as a string (e.g., "1.12.4").
- It is a read-only property; you cannot modify it.
- Useful for debugging or ensuring compatibility in scripts.
How jquery Property Works?
Whenever you include the jQuery library, it attaches a jquery property to its global function. Any jQuery object you create inherits this property, making it easy to retrieve the version at runtime.
Syntax
Example
var version = $.fn.jquery;
Display jQuery Version
This example prints the version number of the loaded jQuery library onto the page.
Example
$(document).ready(function() {
var version = $.fn.jquery;
$("#result").text("Current jQuery version: " + version);
});
fn is an alias for jQuery.prototype; it’s where all jQuery methods (like hide(), css(), etc.) are defined. $.fn.jquery accesses the version string from jQuery’s prototype directly.