Is there any way to get the 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.
6
Answers
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:
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 :
This spinoff of the Constructor method adds a fallback plugin and returns an array:
You can access the major revision with
version[0]
, of course.you can find bootstrap version here: https://getbootstrap.com/docs/4.3/getting-started/javascript/#version-numbers
Checked on the jQuery-less Bootstrap5, to get the version you just neeed
If you want a solution that works for all the currently supported versions of Bootstrap (3.x, 4.x, 5.x), this should work: