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
Instead of using parseInt
as i saw in one of the answers above i would suggest to use parseFloat
as mentioned below
var _jQueryVer = parseFloat('.'+$().jquery.replace(/\./g, ''));
/* Here the value of _jQueryVer would be 0.1012 if the jQuery version is 1.0.12
which in case of parseInt would be 1012 which is higher than
140 (if jQuery version is 1.4.0)
*/
if(_jQueryVer < 0.130) {
alert('Please upgrade jQuery to version 1.3.0 or higher');
}