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
I feel like all the solutions are rather bulky, is mine below missing something?
Compressed version:
(parseInt(jQuery.fn.jquery.split('.').join('')) > 140) ? alert("Running jquery greater than 1.4.0") : alert("current jquery version is 1.4.0 or less");
Long version for clarity:
// get version as a string and get rid of the periods.
version = jQuery.fn.jquery.split('.').join('');
// Make into one long number for easy comparison. Example, 171, or 141.
version = parseInt(version);
if(version > 141){
alert("We're using a version greater than 1.4.1");
}else{
alert("jQuery version is 1.4.1 or lower");
}