Is there any way to get bootstrap
version via calling a function? I did some research but couldn't find any way, the 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 the comments are removed how do I get the bootstrap version? Bootstrap plugins have a version defined in them but I'm looking for the general bootstrap version, not version of a particular plugin.
Nearly all Bootstrap plugins can be enabled and configured through HTML alone with data attributes (our preferred way of using JavaScript functionality). Be sure to only use one set of data attributes on a single element (e.g., you cannot trigger a tooltip and modal from the same button.)
We can check Bootstrap-specific method is available or not. Syntax: var bootstrap = (typeof $(). "Bootstrap-specific method" == 'function');
The version of each of Bootstrap's jQuery plugins can be accessed via the VERSION property of the plugin's constructor. For example, for the tooltip plugin:
$.fn.tooltip.Constructor.VERSION // => "3.3.7"
src //getbootstrap.com/javascript/#js-version-nums
if you mean from the css, then yu ahve to AJAX the file and .match(/v[.\d]+[.\d]/);
You can use this code 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' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With