Created
August 15, 2017 20:23
-
-
Save jarrettbarnett/ae3323672e1f0dcdb56a6faf37428feb to your computer and use it in GitHub Desktop.
Get Bootstrap Version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getBootstrapVersion = function () { | |
var deferred = $.Deferred(); | |
var script = $('script[src*="bootstrap"]'); | |
if (script.length == 0) { | |
return deferred.reject(); | |
} | |
var src = script.attr('src'); | |
$.get(src).done(function(response) { | |
var matches = response.match(/(?!v)([.\d]+[.\d])/); | |
if (matches && matches.length > 0) { | |
version = matches[0]; | |
deferred.resolve(version); | |
} | |
}); | |
return deferred; | |
}; | |
getBootstrapVersion().done(function(version) { | |
console.log(version); // '3.3.5' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment