Return to Snippet

Revision: 63695
at May 30, 2013 23:54 by lubosfonio


Initial Code
function isJQueryValidVersion(version) {
  var validVersion = true;
  if (typeof jQuery != 'undefined') {
    if ((typeof version != 'undefined') && (version != '')) {
      var neededVersion = version.split('.');
      var jQver = jQuery.fn.jquery.split('.');
      for (var i = 0; i < jQver.length; i++) {
        var actset = parseInt(jQver[i]);
        if (neededVersion.length >= (i+1)) {
          var actneeded = parseInt(neededVersion[i]);
	  if (actneeded > actset) {
	    validVersion = false;
	    break;
	  } else if (actneeded < actset) {
	    validVersion = true;
	    break;
	  } else {
	    continue;
	  }
        } else {
	  if (actset >= 0) {
	    validVersion = true;
	    break;
	  }
        }
      }
    }
  } else {
    validVersion = false;
  }
  return validVersion;
}

Initial URL

                                

Initial Description
Checks if JQuery is loaded and then checks if loaded version of JQuery >= needed version

Initial Title
Jquery version check vs. needed version

Initial Tags
javascript, jquery

Initial Language
jQuery