How can I get the bootstrap version via javascript?
Is there a way to get the version bootstrap
through a function call? I've done some research but couldn't find any way, version information is included in the comments at the beginning like this:
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under the MIT license
*/
But in case of deleting comments, how can I get the bootstrap version? Bootstrap modules have a version defined in them, but I'm looking for a generic bootstrap version, not a specific plugin version.
source to share
A version of each of the jQuery Bootstrap plugins can be accessed through the VERSION property of the plugin constructor. For example, for a tooltip plugin:
$. fn.tooltip.Constructor.VERSION // => "3.3.7"
src // getbootstrap.com / javascript / # js-version-nums
if you mean from css then yu ahve to the AJAX file and .match(/v[.\d]+[.\d]/);
source to share
This code can be found here :
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.4'
});
source to share
You can find the bootstrap version here: https://getbootstrap.com/docs/4.3/getting-started/javascript/#version-numbers
$.fn.tooltip.Constructor.VERSION // => "4.3.1"
source to share