When writing a new jQuery plugin is there a straightforward way of checking that the current version of jQuery is above a certain number? Displaying a warning or logging an
$().jquery;
or
jQuery.fn.jquery;
See my answer here: jQuery Version Compatibility Detection
Split the jQuery version string into numbers to test their value. Some version strings do not contain an increment, so make them 0.
var
version = $.fn.jquery.split('.'),
versionMinor = parseFloat(version[1]),
versionIncrement = parseFloat(version[2] || '0');
if (versionMinor === 4 && versionIncrement < 3 || versionMinor < 4) {
$.error('Requires jQuery 1.4.3 or higher to support ...');
}
Use the jQuery error function to prevent execution with an explanation to the developer.