/ Published in: jQuery
Checks if JQuery is loaded and then checks if loaded version of JQuery >= needed version
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }