Last Updated: February 25, 2016
·
449
· itaqua

jQuery Version Verifier

The following is a little snipplet to check if the current JQuery version installed is at leas whatever you need...

example: isJQueryVersionAtLeast(1,2,3)

I wrote this down because i found that the usual way of doing it through REG EXPs fails on mayor versions.

function isJQueryVersionAtLeast(mayor, minor, fix){
    var minVersion = [mayor,minor, fix];

    var currVersion =  $.map($.fn.jquery.split('.'), function(item, index){
        return parseInt(item);
    });

    return currVersion[0] > minVersion[0] ||
            (currVersion[0] == minVersion[0] && 
                 (currVersion[1] > minVersion[1] ||
                      (currVersion[1] == minVersion[1] && 
                          currVersion[2] >= minVersion[2])));
}